Merge pull request #67545 from sttts/sttts-auth-optional-kubeconfig

Automatic merge from submit-queue (batch tested with PRs 66960, 67545). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

delegated authn/z: optionally opt-out of mandatory authn/authz kubeconfig

This adds `RemoteKubeConfigFileOptional` field to the delegated authn/z option structs. If set to true, the authn/z kubeconfig file flags are optional. If no kubeconfig is given, all token requests are considered to be anonymous and no client CA is looked up in the cluster.

Prerequisite for https://github.com/kubernetes/kubernetes/pull/64149 and https://github.com/kubernetes/kubernetes/pull/67069.

Kubernetes-commit: 1b3a2dd0830ca0e02d5b95d2ecc0161d0c93a0c7
This commit is contained in:
Kubernetes Publisher 2018-08-28 13:47:18 -07:00
commit 87935b98dd
2 changed files with 89 additions and 86 deletions

166
Godeps/Godeps.json generated
View File

@ -272,335 +272,335 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/coordination/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/scheduling/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "2b55f61af91985c3abb7a28a018764c389c00556"
"Rev": "d150a58332329a1cd3e80959b04f5487a8be7149"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "017bf4f8f5884203a401400e511f4c8fc2eded21"
"Rev": "c6b66c9c507abbefa93ad83f7fe8c9b52ca1ae30"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",

View File

@ -18,6 +18,7 @@ package rest
import (
"context"
"errors"
"fmt"
"io/ioutil"
"net"
@ -44,6 +45,8 @@ const (
DefaultBurst int = 10
)
var ErrNotInCluster = errors.New("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined")
// Config holds the common attributes that can be passed to a Kubernetes client on
// initialization.
type Config struct {
@ -308,12 +311,12 @@ func DefaultKubernetesUserAgent() string {
// InClusterConfig returns a config object which uses the service account
// kubernetes gives to pods. It's intended for clients that expect to be
// running inside a pod running on kubernetes. It will return an error if
// called from a process not running in a kubernetes environment.
// running inside a pod running on kubernetes. It will return ErrNotInCluster
// if called from a process not running in a kubernetes environment.
func InClusterConfig() (*Config, error) {
host, port := os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT")
if len(host) == 0 || len(port) == 0 {
return nil, fmt.Errorf("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined")
return nil, ErrNotInCluster
}
token, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/token")