diff --git a/cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml b/cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml index 3a92b0fcb7f64..d4d40172ebe07 100644 --- a/cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml +++ b/cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml @@ -34,7 +34,7 @@ spec: name: grafana env: - name: INFLUXDB_EXTERNAL_URL - value: /api/v1beta3/proxy/namespaces/default/services/monitoring-influxdb:api/db/ + value: /api/v1/proxy/namespaces/default/services/monitoring-influxdb:api/db/ - name: INFLUXDB_HOST value: monitoring-influxdb - name: INFLUXDB_PORT diff --git a/cluster/addons/fluentd-elasticsearch/es-service.yaml b/cluster/addons/fluentd-elasticsearch/es-service.yaml index 1e1388cc4f23c..572df92b9c58e 100644 --- a/cluster/addons/fluentd-elasticsearch/es-service.yaml +++ b/cluster/addons/fluentd-elasticsearch/es-service.yaml @@ -1,4 +1,4 @@ -apiVersion: v1beta3 +apiVersion: v1 kind: Service metadata: name: elasticsearch-logging diff --git a/cluster/addons/fluentd-elasticsearch/kibana-service.yaml b/cluster/addons/fluentd-elasticsearch/kibana-service.yaml index af4d3d8830432..3a1815c5df057 100644 --- a/cluster/addons/fluentd-elasticsearch/kibana-service.yaml +++ b/cluster/addons/fluentd-elasticsearch/kibana-service.yaml @@ -1,5 +1,4 @@ - -apiVersion: v1beta3 +apiVersion: v1 kind: Service metadata: name: kibana-logging diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index caef36e7cf5cb..dcd4fa4e07dcd 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -728,7 +728,7 @@ function kube-up { -H "Authorization: Bearer ${KUBE_BEARER_TOKEN}" \ ${secure} \ --max-time 5 --fail --output /dev/null --silent \ - "https://${KUBE_MASTER_IP}/api/v1beta3/pods"; do + "https://${KUBE_MASTER_IP}/api/v1/pods"; do printf "." sleep 2 done diff --git a/cluster/images/hyperkube/master-multi.json b/cluster/images/hyperkube/master-multi.json index 0869b669043ac..b0adc6c61eb16 100644 --- a/cluster/images/hyperkube/master-multi.json +++ b/cluster/images/hyperkube/master-multi.json @@ -1,5 +1,5 @@ { -"apiVersion": "v1beta3", +"apiVersion": "v1", "kind": "Pod", "metadata": {"name":"k8s-master"}, "spec":{ diff --git a/cluster/images/hyperkube/master.json b/cluster/images/hyperkube/master.json index 07b4ac834ee02..57e75b57542d0 100644 --- a/cluster/images/hyperkube/master.json +++ b/cluster/images/hyperkube/master.json @@ -1,5 +1,5 @@ { -"apiVersion": "v1beta3", +"apiVersion": "v1", "kind": "Pod", "metadata": {"name":"k8s-master"}, "spec":{ diff --git a/cluster/saltbase/salt/etcd/etcd.manifest b/cluster/saltbase/salt/etcd/etcd.manifest index 8e2107f3c0f67..f263eb5d042d3 100644 --- a/cluster/saltbase/salt/etcd/etcd.manifest +++ b/cluster/saltbase/salt/etcd/etcd.manifest @@ -1,5 +1,5 @@ { -"apiVersion": "v1beta3", +"apiVersion": "v1", "kind": "Pod", "metadata": {"name":"etcd-server"}, "spec":{ diff --git a/cluster/saltbase/salt/fluentd-es/fluentd-es.yaml b/cluster/saltbase/salt/fluentd-es/fluentd-es.yaml index 7c16cce73f743..ef19173c430bd 100644 --- a/cluster/saltbase/salt/fluentd-es/fluentd-es.yaml +++ b/cluster/saltbase/salt/fluentd-es/fluentd-es.yaml @@ -1,4 +1,4 @@ -apiVersion: v1beta3 +apiVersion: v1 kind: Pod metadata: name: fluentd-elasticsearch diff --git a/cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml b/cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml index 7433852be58db..90f0343361d2b 100644 --- a/cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml +++ b/cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml @@ -1,4 +1,4 @@ -apiVersion: v1beta3 +apiVersion: v1 kind: Pod metadata: name: fluentd-cloud-logging diff --git a/cluster/saltbase/salt/kube-addons/kube-addon-update.sh b/cluster/saltbase/salt/kube-addons/kube-addon-update.sh index a3c3f29504d95..083b0ee16bb26 100755 --- a/cluster/saltbase/salt/kube-addons/kube-addon-update.sh +++ b/cluster/saltbase/salt/kube-addons/kube-addon-update.sh @@ -192,7 +192,7 @@ function run-until-success() { # returns a list of / pairs (nsnames) function get-addon-nsnames-from-server() { local -r obj_type=$1 - "${KUBECTL}" get "${obj_type}" --all-namespaces -o template -t "{{range.items}}{{.metadata.namespace}}/{{.metadata.name}} {{end}}" --api-version=v1beta3 -l kubernetes.io/cluster-service=true + "${KUBECTL}" get "${obj_type}" --all-namespaces -o template -t "{{range.items}}{{.metadata.namespace}}/{{.metadata.name}} {{end}}" --api-version=v1 -l kubernetes.io/cluster-service=true } # returns the characters after the last separator (including) diff --git a/cluster/saltbase/salt/kube-addons/kube-addons.sh b/cluster/saltbase/salt/kube-addons/kube-addons.sh index 1ecc2bdd25f89..4cbb1cc1fb8fb 100644 --- a/cluster/saltbase/salt/kube-addons/kube-addons.sh +++ b/cluster/saltbase/salt/kube-addons/kube-addons.sh @@ -74,7 +74,7 @@ EOF local -r kubeconfig_base64=$(echo "${kubeconfig}" | base64 -w0) read -r -d '' secretyaml <"${APISERVER_LOG}" 2>&1 & diff --git a/hack/test-cmd.sh b/hack/test-cmd.sh index 30a0de46d8f40..2fd0a42046f2c 100755 --- a/hack/test-cmd.sh +++ b/hack/test-cmd.sh @@ -125,7 +125,7 @@ kube::util::wait_for_url "http://127.0.0.1:${KUBELET_HEALTHZ_PORT}/healthz" "kub # Start kube-apiserver kube::log::status "Starting kube-apiserver" -"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \ +KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \ --address="127.0.0.1" \ --public_address_override="127.0.0.1" \ --port="${API_PORT}" \ @@ -134,6 +134,7 @@ kube::log::status "Starting kube-apiserver" --kubelet_port=${KUBELET_PORT} \ --runtime_config=api/v1beta3 \ --runtime_config=api/v1 \ + --runtime_config=api/v1beta3 \ --cert_dir="${TMPDIR:-/tmp/}" \ --service-cluster-ip-range="10.0.0.0/24" 1>&2 & APISERVER_PID=$! @@ -148,17 +149,14 @@ kube::log::status "Starting controller-manager" CTLRMGR_PID=$! kube::util::wait_for_url "http://127.0.0.1:${CTLRMGR_PORT}/healthz" "controller-manager" -kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/api/v1beta3/nodes/127.0.0.1" "apiserver(nodes)" +kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/api/v1/nodes/127.0.0.1" "apiserver(nodes)" # Expose kubectl directly for readability PATH="${KUBE_OUTPUT_HOSTBIN}":$PATH -kube_api_versions=( - "" - v1beta3 - v1 -) -for version in "${kube_api_versions[@]}"; do +runTests() { + version="$1" + echo "Testing api version: $1" if [[ -z "${version}" ]]; then kube_flags=( -s "http://127.0.0.1:${API_PORT}" @@ -377,7 +375,7 @@ for version in "${kube_api_versions[@]}"; do kubectl create -f examples/limitrange/valid-pod.json "${kube_flags[@]}" # Post-condition: valid-pod POD is running kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" 'valid-pod:' - + ## Patch pod can change image # Command kubectl patch "${kube_flags[@]}" pod valid-pod -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "nginx"}]}}' @@ -523,7 +521,7 @@ for version in "${kube_api_versions[@]}"; do kubectl create -f - "${kube_flags[@]}" << __EOF__ { "kind": "Service", - "apiVersion": "v1beta3", + "apiVersion": "v1", "metadata": { "name": "service-${version}-test" }, @@ -784,6 +782,15 @@ __EOF__ fi kube::test::clear_all +} + +kube_api_versions=( + "" + v1beta3 + v1 +) +for version in "${kube_api_versions[@]}"; do + KUBE_API_VERSIONS="v1,v1beta3" runTests "${version}" done kube::log::status "TEST PASSED" diff --git a/hack/test-go.sh b/hack/test-go.sh index a3dc143d0e71b..dbbf2f3f4549a 100755 --- a/hack/test-go.sh +++ b/hack/test-go.sh @@ -53,7 +53,7 @@ KUBE_RACE=${KUBE_RACE:-} # use KUBE_RACE="-race" to enable race testing # Set to the goveralls binary path to report coverage results to Coveralls.io. KUBE_GOVERALLS_BIN=${KUBE_GOVERALLS_BIN:-} # Comma separated list of API Versions that should be tested. -KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1beta3,v1"} +KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,v1beta3"} # Run tests with the standard (registry) and a custom etcd prefix # (kubernetes.io/registry). KUBE_TEST_ETCD_PREFIXES=${KUBE_TEST_ETCD_PREFIXES:-"registry,kubernetes.io/registry"} @@ -218,7 +218,7 @@ for (( i=0, j=0; ; )); do apiVersion=${apiVersions[i]} etcdPrefix=${etcdPrefixes[j]} echo "Running tests for APIVersion: $apiVersion with etcdPrefix: $etcdPrefix" - KUBE_API_VERSION="${apiVersion}" ETCD_PREFIX=${etcdPrefix} runTests "$@" + KUBE_API_VERSION="${apiVersion}" KUBE_API_VERSIONS="v1,v1beta3" ETCD_PREFIX=${etcdPrefix} runTests "$@" i=${i}+1 j=${j}+1 if [[ i -eq ${apiVersionsCount} ]] && [[ j -eq ${etcdPrefixesCount} ]]; then diff --git a/hack/test-integration.sh b/hack/test-integration.sh index 699bd98d15167..a92e3519d42f9 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -25,7 +25,7 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" # Comma separated list of API Versions that should be tested. -KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1beta3,v1"} +KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,v1beta3"} KUBE_INTEGRATION_TEST_MAX_CONCURRENCY=${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY:-"-1"} LOG_LEVEL=${LOG_LEVEL:-2} @@ -39,20 +39,22 @@ runTests() { kube::etcd::start kube::log::status "Running integration test cases" + KUBE_GOFLAGS="-tags 'integration no-docker' " \ KUBE_RACE="-race" \ KUBE_TEST_API_VERSIONS="$1" \ + KUBE_API_VERSIONS="v1,v1beta3" \ "${KUBE_ROOT}/hack/test-go.sh" test/integration kube::log::status "Running integration test scenario" - "${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" \ + KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" \ --max-concurrency="${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY}" cleanup } -"${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration +KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration # Run cleanup to stop etcd on interrupt or other kill signal. trap cleanup EXIT diff --git a/hack/update-swagger-spec.sh b/hack/update-swagger-spec.sh index cfe3639c955b9..e85abd4b5953d 100755 --- a/hack/update-swagger-spec.sh +++ b/hack/update-swagger-spec.sh @@ -46,14 +46,14 @@ KUBELET_PORT=${KUBELET_PORT:-10250} # Start kube-apiserver kube::log::status "Starting kube-apiserver" -"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \ +KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \ --address="127.0.0.1" \ --public_address_override="127.0.0.1" \ --port="${API_PORT}" \ --etcd_servers="http://${ETCD_HOST}:${ETCD_PORT}" \ --public_address_override="127.0.0.1" \ --kubelet_port=${KUBELET_PORT} \ - --runtime_config=api/legacy=false \ + --runtime_config=api/v1beta3 \ --service-cluster-ip-range="10.0.0.0/24" 1>&2 & APISERVER_PID=$! diff --git a/pkg/api/latest/latest.go b/pkg/api/latest/latest.go index c4ff2f5f69ee9..49446577b5c87 100644 --- a/pkg/api/latest/latest.go +++ b/pkg/api/latest/latest.go @@ -34,7 +34,7 @@ var Version string // OldestVersion is the string that represents the oldest server version supported, // for client code that wants to hardcode the lowest common denominator. -const OldestVersion = "v1beta3" +var OldestVersion string // Versions is the list of versions that are recognized in code. The order provided // may be assumed to be least feature rich to most feature rich, and clients may @@ -67,6 +67,7 @@ var userResources = []string{"rc", "svc", "pods", "pvc"} func init() { // Use the first API version in the list of registered versions as the latest. Version = registered.RegisteredVersions[0] + OldestVersion = registered.RegisteredVersions[len(registered.RegisteredVersions)-1] Codec = runtime.CodecFor(api.Scheme, Version) // Put the registered versions in Versions in reverse order. versions := registered.RegisteredVersions diff --git a/pkg/api/serialization_test.go b/pkg/api/serialization_test.go index 5b41239d80e6f..be451acfbc687 100644 --- a/pkg/api/serialization_test.go +++ b/pkg/api/serialization_test.go @@ -26,9 +26,8 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" apitesting "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testing" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/davecgh/go-spew/spew" @@ -88,13 +87,10 @@ func roundTripSame(t *testing.T, item runtime.Object, except ...string) { set := util.NewStringSet(except...) seed := rand.Int63() fuzzInternalObject(t, "", item, seed) - if !set.Has("v1beta3") { - fuzzInternalObject(t, "v1beta3", item, seed) - roundTrip(t, v1beta3.Codec, item) - } - if !set.Has("v1") { - fuzzInternalObject(t, "v1", item, seed) - roundTrip(t, v1.Codec, item) + version := testapi.Version() + if !set.Has(version) { + fuzzInternalObject(t, version, item, seed) + roundTrip(t, testapi.Codec(), item) } } diff --git a/pkg/api/v1beta3/conversion_test.go b/pkg/api/v1beta3/conversion_test.go index c9433cba8a90b..aa90f33d6d451 100644 --- a/pkg/api/v1beta3/conversion_test.go +++ b/pkg/api/v1beta3/conversion_test.go @@ -84,7 +84,7 @@ func TestBadSecurityContextConversion(t *testing.T) { c *versioned.Container err string }{ - // this use case must use true for the container and false for the sc. Otherwise the defaulter + // this use case must use true for the container and false for the sc. Otherwise the defaulter // will assume privileged was left undefined (since it is the default value) and copy the // sc setting upwards "mismatched privileged": { diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 83678758a48a3..82e2703a21465 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -24,6 +24,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" utilerrors "github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors" @@ -556,7 +557,7 @@ func TestValidateEnv(t *testing.T) { Name: "abc", ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1beta3", + APIVersion: testapi.Version(), FieldPath: "metadata.name", }, }, @@ -588,7 +589,7 @@ func TestValidateEnv(t *testing.T) { Value: "foo", ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1beta3", + APIVersion: testapi.Version(), FieldPath: "metadata.name", }, }, @@ -601,7 +602,7 @@ func TestValidateEnv(t *testing.T) { Name: "abc", ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1beta3", + APIVersion: testapi.Version(), }, }, }}, @@ -626,7 +627,7 @@ func TestValidateEnv(t *testing.T) { ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.whoops", - APIVersion: "v1beta3", + APIVersion: testapi.Version(), }, }, }}, @@ -639,7 +640,7 @@ func TestValidateEnv(t *testing.T) { ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ FieldPath: "status.phase", - APIVersion: "v1beta3", + APIVersion: testapi.Version(), }, }, }}, diff --git a/pkg/client/helper.go b/pkg/client/helper.go index 42645757ee971..d29a7db800db0 100644 --- a/pkg/client/helper.go +++ b/pkg/client/helper.go @@ -31,7 +31,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/version" @@ -174,7 +173,7 @@ func MatchesServerVersion(client *Client, c *Config) error { // stderr and try client's registered versions in order of preference. // - If version is config default, and the server does not support it, // return an error. -func NegotiateVersion(client *Client, c *Config, version string) (string, error) { +func NegotiateVersion(client *Client, c *Config, version string, clientRegisteredVersions []string) (string, error) { var err error if client == nil { client, err = New(c) @@ -183,7 +182,7 @@ func NegotiateVersion(client *Client, c *Config, version string) (string, error) } } clientVersions := util.StringSet{} - for _, v := range registered.RegisteredVersions { + for _, v := range clientRegisteredVersions { clientVersions.Insert(v) } apiVersions, err := client.ServerAPIVersions() @@ -214,7 +213,7 @@ func NegotiateVersion(client *Client, c *Config, version string) (string, error) } } - for _, clientVersion := range registered.RegisteredVersions { + for _, clientVersion := range clientRegisteredVersions { if serverVersions.Has(clientVersion) { // Version was not explicitly requested in command config (--api-version). // Ok to fall back to a supported version with a warning. @@ -225,7 +224,7 @@ func NegotiateVersion(client *Client, c *Config, version string) (string, error) } } return "", fmt.Errorf("Failed to negotiate an api version. Server supports: %v. Client supports: %v.", - serverVersions, registered.RegisteredVersions) + serverVersions, clientRegisteredVersions) } // NewOrDie creates a Kubernetes client and panics if the provided API version is not recognized. diff --git a/pkg/client/helper_test.go b/pkg/client/helper_test.go index ab2897c0686f4..a222f616dd131 100644 --- a/pkg/client/helper_test.go +++ b/pkg/client/helper_test.go @@ -333,39 +333,44 @@ func TestNegotiateVersion(t *testing.T) { tests := []struct { name, version, expectedVersion string serverVersions []string + clientVersions []string config *Config expectErr bool }{ { name: "server supports client default", - version: "v1", - expectedVersion: "v1", + version: "version1", config: &Config{}, - serverVersions: []string{"v1beta3", "v1"}, + serverVersions: []string{"version1", testapi.Version()}, + clientVersions: []string{"version1", testapi.Version()}, + expectedVersion: "version1", expectErr: false, }, { name: "server falls back to client supported", - version: "v1", - expectedVersion: "v1beta3", + version: testapi.Version(), config: &Config{}, - serverVersions: []string{"v1beta3"}, + serverVersions: []string{"version1"}, + clientVersions: []string{"version1", testapi.Version()}, + expectedVersion: "version1", expectErr: false, }, { name: "explicit version supported", version: "", - expectedVersion: "v1", - config: &Config{Version: "v1"}, - serverVersions: []string{"v1beta3", "v1"}, + config: &Config{Version: testapi.Version()}, + serverVersions: []string{"version1", testapi.Version()}, + clientVersions: []string{"version1", testapi.Version()}, + expectedVersion: testapi.Version(), expectErr: false, }, { name: "explicit version not supported", version: "", + config: &Config{Version: testapi.Version()}, + serverVersions: []string{"version1"}, + clientVersions: []string{"version1", testapi.Version()}, expectedVersion: "", - config: &Config{Version: "v1"}, - serverVersions: []string{"v1beta3"}, expectErr: true, }, } @@ -384,7 +389,7 @@ func TestNegotiateVersion(t *testing.T) { } c := NewOrDie(test.config) c.Client = fakeClient.Client - response, err := NegotiateVersion(c, test.config, test.version) + response, err := NegotiateVersion(c, test.config, test.version, test.clientVersions) if err == nil && test.expectErr { t.Errorf("expected error, got nil for [%s].", test.name) } diff --git a/pkg/kubectl/cmd/util/clientcache.go b/pkg/kubectl/cmd/util/clientcache.go index 9ddf8718dc730..9b8a2e36f8372 100644 --- a/pkg/kubectl/cmd/util/clientcache.go +++ b/pkg/kubectl/cmd/util/clientcache.go @@ -17,6 +17,7 @@ limitations under the License. package util import ( + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd" ) @@ -59,7 +60,7 @@ func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, er } // TODO: have a better config copy method config := *c.defaultConfig - negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version) + negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version, registered.RegisteredVersions) if err != nil { return nil, err } diff --git a/pkg/kubectl/cmd/util/helpers_test.go b/pkg/kubectl/cmd/util/helpers_test.go index cf1e36988dab1..5b335a068dec6 100644 --- a/pkg/kubectl/cmd/util/helpers_test.go +++ b/pkg/kubectl/cmd/util/helpers_test.go @@ -17,6 +17,7 @@ limitations under the License. package util import ( + "fmt" "io/ioutil" "net/http" "net/http/httptest" @@ -26,6 +27,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors" ) @@ -45,7 +47,7 @@ func TestMerge(t *testing.T) { Name: "foo", }, }, - fragment: `{ "apiVersion": "v1beta3" }`, + fragment: fmt.Sprintf(`{ "apiVersion": "%s" }`, testapi.Version()), expected: &api.Pod{ ObjectMeta: api.ObjectMeta{ Name: "foo", @@ -77,7 +79,7 @@ func TestMerge(t *testing.T) { }, }, }, - fragment: `{ "apiVersion": "v1beta3", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, + fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, testapi.Version()), expected: &api.Pod{ ObjectMeta: api.ObjectMeta{ Name: "foo", @@ -103,7 +105,7 @@ func TestMerge(t *testing.T) { Name: "foo", }, }, - fragment: `{ "apiVersion": "v1beta3", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, + fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, testapi.Version()), expected: &api.Pod{ ObjectMeta: api.ObjectMeta{ Name: "foo", @@ -142,7 +144,7 @@ func TestMerge(t *testing.T) { obj: &api.Service{ Spec: api.ServiceSpec{}, }, - fragment: `{ "apiVersion": "v1beta3", "spec": { "ports": [ { "port": 0 } ] } }`, + fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "ports": [ { "port": 0 } ] } }`, testapi.Version()), expected: &api.Service{ Spec: api.ServiceSpec{ SessionAffinity: "None", @@ -165,145 +167,7 @@ func TestMerge(t *testing.T) { }, }, }, - fragment: `{ "apiVersion": "v1beta3", "spec": { "selector": { "version": "v2" } } }`, - expected: &api.Service{ - Spec: api.ServiceSpec{ - SessionAffinity: "None", - Type: api.ServiceTypeClusterIP, - Selector: map[string]string{ - "version": "v2", - }, - }, - }, - }, - { - kind: "Pod", - obj: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - }, - }, - fragment: `{ "apiVersion": "v1" }`, - expected: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - }, - Spec: api.PodSpec{ - RestartPolicy: api.RestartPolicyAlways, - DNSPolicy: api.DNSClusterFirst, - }, - }, - }, - /* TODO: uncomment this test once Merge is updated to use - strategic-merge-patch. See #8449. - { - kind: "Pod", - obj: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - }, - Spec: api.PodSpec{ - Containers: []api.Container{ - api.Container{ - Name: "c1", - Image: "red-image", - }, - api.Container{ - Name: "c2", - Image: "blue-image", - }, - }, - }, - }, - fragment: `{ "apiVersion": "v1", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, - expected: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - }, - Spec: api.PodSpec{ - Containers: []api.Container{ - api.Container{ - Name: "c1", - Image: "green-image", - }, - api.Container{ - Name: "c2", - Image: "blue-image", - }, - }, - }, - }, - }, */ - { - kind: "Pod", - obj: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - }, - }, - fragment: `{ "apiVersion": "v1", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, - expected: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - }, - Spec: api.PodSpec{ - Volumes: []api.Volume{ - { - Name: "v1", - VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}, - }, - { - Name: "v2", - VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}, - }, - }, - RestartPolicy: api.RestartPolicyAlways, - DNSPolicy: api.DNSClusterFirst, - }, - }, - }, - { - kind: "Pod", - obj: &api.Pod{}, - fragment: "invalid json", - expected: &api.Pod{}, - expectErr: true, - }, - { - kind: "Service", - obj: &api.Service{}, - fragment: `{ "apiVersion": "badVersion" }`, - expectErr: true, - }, - { - kind: "Service", - obj: &api.Service{ - Spec: api.ServiceSpec{}, - }, - fragment: `{ "apiVersion": "v1", "spec": { "ports": [ { "port": 0 } ] } }`, - expected: &api.Service{ - Spec: api.ServiceSpec{ - SessionAffinity: "None", - Type: api.ServiceTypeClusterIP, - Ports: []api.ServicePort{ - { - Protocol: api.ProtocolTCP, - Port: 0, - }, - }, - }, - }, - }, - { - kind: "Service", - obj: &api.Service{ - Spec: api.ServiceSpec{ - Selector: map[string]string{ - "version": "v1", - }, - }, - }, - fragment: `{ "apiVersion": "v1", "spec": { "selector": { "version": "v2" } } }`, + fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "selector": { "version": "v2" } } }`, testapi.Version()), expected: &api.Service{ Spec: api.ServiceSpec{ SessionAffinity: "None", diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 4957f57906dd3..a9713e6bb1ea2 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -34,6 +34,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" apierrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/record" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" @@ -1172,7 +1173,7 @@ func TestMakeEnvironmentVariables(t *testing.T) { Name: "POD_NAME", ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1beta3", + APIVersion: testapi.Version(), FieldPath: "metadata.name", }, }, @@ -1181,7 +1182,7 @@ func TestMakeEnvironmentVariables(t *testing.T) { Name: "POD_NAMESPACE", ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1beta3", + APIVersion: testapi.Version(), FieldPath: "metadata.namespace", }, }, @@ -1208,7 +1209,7 @@ func TestMakeEnvironmentVariables(t *testing.T) { Name: "POD_NAME", ValueFrom: &api.EnvVarSource{ FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1beta3", + APIVersion: testapi.Version(), FieldPath: "metadata.name", }, }, diff --git a/pkg/runtime/conversion_generation_test.go b/pkg/runtime/conversion_generation_test.go index 006494d8614f1..4e89413e5f056 100644 --- a/pkg/runtime/conversion_generation_test.go +++ b/pkg/runtime/conversion_generation_test.go @@ -26,6 +26,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" @@ -131,19 +132,16 @@ func compareBuffers(t *testing.T, generatedFile string, existing, generated byte } func TestNoManualChangesToGenerateConversions(t *testing.T) { - versions := []string{"v1beta3", "v1"} + version := testapi.Version() + fileName := fmt.Sprintf("../../pkg/api/%s/conversion_generated.go", version) - for _, version := range versions { - fileName := fmt.Sprintf("../../pkg/api/%s/conversion_generated.go", version) + existingFunctions := bufferExistingGeneratedCode(t, fileName) + generatedFunctions := generateConversions(t, version) - existingFunctions := bufferExistingGeneratedCode(t, fileName) - generatedFunctions := generateConversions(t, version) + functionsTxt := fmt.Sprintf("%s.functions.txt", version) + ioutil.WriteFile(functionsTxt, generatedFunctions.Bytes(), os.FileMode(0644)) - functionsTxt := fmt.Sprintf("%s.functions.txt", version) - ioutil.WriteFile(functionsTxt, generatedFunctions.Bytes(), os.FileMode(0644)) - - if ok := compareBuffers(t, functionsTxt, existingFunctions, generatedFunctions); ok { - os.Remove(functionsTxt) - } + if ok := compareBuffers(t, functionsTxt, existingFunctions, generatedFunctions); ok { + os.Remove(functionsTxt) } } diff --git a/pkg/runtime/deep_copy_generation_test.go b/pkg/runtime/deep_copy_generation_test.go index 47c12208f2e6f..eb28a8160b15f 100644 --- a/pkg/runtime/deep_copy_generation_test.go +++ b/pkg/runtime/deep_copy_generation_test.go @@ -25,6 +25,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" @@ -64,7 +65,7 @@ func generateDeepCopies(t *testing.T, version string) bytes.Buffer { } func TestNoManualChangesToGenerateDeepCopies(t *testing.T) { - versions := []string{"api", "v1beta3", "v1"} + versions := []string{"api", testapi.Version()} for _, version := range versions { fileName := "" diff --git a/test/e2e/persistent_volumes.go b/test/e2e/persistent_volumes.go index 8a4d3d2e9a1e4..010a0be19d20e 100644 --- a/test/e2e/persistent_volumes.go +++ b/test/e2e/persistent_volumes.go @@ -21,6 +21,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -162,7 +163,7 @@ func makeCheckPod(ns string, nfsserver string) *api.Pod { return &api.Pod{ TypeMeta: api.TypeMeta{ Kind: "Pod", - APIVersion: "v1beta3", + APIVersion: testapi.Version(), }, ObjectMeta: api.ObjectMeta{ GenerateName: "checker-", diff --git a/test/e2e/proxy.go b/test/e2e/proxy.go index 4a04ffec0567b..41a82765509b3 100644 --- a/test/e2e/proxy.go +++ b/test/e2e/proxy.go @@ -24,6 +24,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -34,9 +35,8 @@ import ( ) var _ = Describe("Proxy", func() { - for _, version := range []string{"v1beta3", "v1"} { - Context("version "+version, func() { proxyContext(version) }) - } + version := testapi.Version() + Context("version "+version, func() { proxyContext(version) }) }) const ( diff --git a/www/README.md b/www/README.md index e473363992c9e..26beaf732d0c2 100644 --- a/www/README.md +++ b/www/README.md @@ -56,7 +56,7 @@ http-server -a localhost -p 8001 Note that you'll need to tell the application where to find the api server by setting the value of the `k8sApiServer` configuration parameter in `www/master/shared/config/development.json` and then rebuilding the application. For example, for a cluster running locally at `localhost:8080`, as described [here](../docs/getting-started-guides/locally.md), you'll want to set it as follows: ``` -"k8sApiServer": "http://localhost:8080/api/v1beta3" +"k8sApiServer": "http://localhost:8080/api/v1" ``` ### Building the app for production