Commit 1c3233a1 authored by Tim Hockin's avatar Tim Hockin

Remove v1beta3

parent 7017f5dc
......@@ -2,10 +2,6 @@
"swaggerVersion": "1.2",
"apis": [
{
"path": "/api/v1beta3",
"description": "API at /api/v1beta3 version v1beta3"
},
{
"path": "/api/v1",
"description": "API at /api/v1 version v1"
},
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,7 +23,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
pkg_runtime "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/golang/glog"
......@@ -32,7 +31,7 @@ import (
var (
functionDest = flag.StringP("funcDest", "f", "-", "Output for conversion functions; '-' means stdout")
version = flag.StringP("version", "v", "v1beta3", "Version for conversion.")
version = flag.StringP("version", "v", "v1", "Version for conversion.")
)
func main() {
......
......@@ -24,7 +24,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
pkg_runtime "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/golang/glog"
......@@ -33,7 +32,7 @@ import (
var (
functionDest = flag.StringP("func-dest", "f", "-", "Output for deep copy functions; '-' means stdout")
version = flag.StringP("version", "v", "v1beta3", "Version for deep copies.")
version = flag.StringP("version", "v", "v1", "Version for deep copies.")
overwrites = flag.StringP("overwrites", "o", "", "Comma-separated overwrites for package names")
)
......
......@@ -152,8 +152,6 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st
glog.Fatalf("no public address for %s", host)
}
// Enable v1beta3 in master only if we are starting the components for that api version.
enableV1Beta3 := apiVersion == "v1beta3"
// Create a master and install handlers into mux.
m := master.New(&master.Config{
EtcdHelper: helper,
......@@ -162,7 +160,6 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st
EnableLogsSupport: false,
EnableProfiling: true,
APIPrefix: "/api",
EnableV1Beta3: enableV1Beta3,
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
ReadWritePort: portNumber,
......@@ -332,7 +329,7 @@ containers:
desc: "static-pod-from-spec",
fileContents: `{
"kind": "Pod",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "static-pod-from-spec"
},
......@@ -611,23 +608,6 @@ func runPatchTest(c *client.Client) {
RemoveLabelBody []byte
RemoveAllLabelsBody []byte
}{
"v1beta3": {
api.JSONPatchType: {
[]byte(`[{"op":"add","path":"/metadata/labels","value":{"foo":"bar","baz":"qux"}}]`),
[]byte(`[{"op":"remove","path":"/metadata/labels/foo"}]`),
[]byte(`[{"op":"remove","path":"/metadata/labels"}]`),
},
api.MergePatchType: {
[]byte(`{"metadata":{"labels":{"foo":"bar","baz":"qux"}}}`),
[]byte(`{"metadata":{"labels":{"foo":null}}}`),
[]byte(`{"metadata":{"labels":null}}`),
},
api.StrategicMergePatchType: {
[]byte(`{"metadata":{"labels":{"foo":"bar","baz":"qux"}}}`),
[]byte(`{"metadata":{"labels":{"foo":null}}}`),
[]byte(`{"metadata":{"labels":{"$patch":"replace"}}}`),
},
},
"v1": {
api.JSONPatchType: {
[]byte(`[{"op":"add","path":"/metadata/labels","value":{"foo":"bar","baz":"qux"}}]`),
......@@ -1027,7 +1007,7 @@ func ServeCachedManifestFile(contents string) (servingAddress string) {
const (
testPodSpecFile = `{
"kind": "Pod",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "container-vm-guestbook-pod-spec"
},
......
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"metadata": {
"name": "nginx-controller",
"labels": {"name": "nginx"}
},
"spec": {
"replicas": 2,
"selector": {"name": "nginx"},
"template": {
"metadata": {
"labels": {"name": "nginx"}
},
"spec": {
"containers": [{
"name": "nginx",
"image": "nginx",
"ports": [{"containerPort": 80}]
}]
}
}
}
}
......@@ -282,9 +282,6 @@ func (s *APIServer) Run(_ []string) error {
}
_ = disableLegacyAPIs // hush the compiler while we don't have legacy APIs to disable.
// v1beta3 is disabled by default. Users can enable it using "api/v1beta3=true"
enableV1beta3 := s.getRuntimeConfigValue("api/v1beta3", false)
// "api/v1={true|false} allows users to enable/disable v1 API.
// This takes preference over api/all and api/legacy, if specified.
disableV1 := disableAllAPIs
......@@ -384,7 +381,6 @@ func (s *APIServer) Run(_ []string) error {
SupportsBasicAuth: len(s.BasicAuthFile) > 0,
Authorizer: authorizer,
AdmissionControl: admissionController,
EnableV1Beta3: enableV1beta3,
DisableV1: disableV1,
MasterServiceNamespace: s.MasterServiceNamespace,
ClusterName: s.ClusterName,
......
......@@ -141,8 +141,7 @@ func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error
func TestExampleObjectSchemas(t *testing.T) {
cases := map[string]map[string]runtime.Object{
"../cmd/integration": {
"v1beta3-controller": &api.ReplicationController{},
"v1-controller": &api.ReplicationController{},
"v1-controller": &api.ReplicationController{},
},
"../examples/guestbook": {
"frontend-controller": &api.ReplicationController{},
......
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"etcd-server"},
"spec":{
......
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-apiserver"},
"spec":{
......
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-controller-manager"},
"spec":{
......
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-scheduler"},
"spec":{
......@@ -36,4 +36,4 @@
"path": "/var/log/kube-scheduler.log"}
}
]
}}
\ No newline at end of file
}}
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"scheduler-master"},
"spec":{
......
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"scheduler-master"},
"spec":{
......
......@@ -125,16 +125,14 @@ 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_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
KUBE_API_VERSIONS="v1" "${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/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=$!
......@@ -237,7 +235,7 @@ runTests() {
kube::test::describe_object_assert pods 'valid-pod' "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Replication Controllers"
### Dump current valid-pod POD
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1beta3 "${kube_flags[@]}")
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1 "${kube_flags[@]}")
### Delete POD valid-pod by id
# Pre-condition: valid-pod POD is running
......@@ -456,8 +454,6 @@ runTests() {
# Pod templates #
#################
# Note: pod templates exist only in v1beta3 and above, so output will always be in that form
### Create PODTEMPLATE
# Pre-condition: no PODTEMPLATE
kube::test::get_object_assert podtemplates "{{range.items}}{{.metadata.name}}:{{end}}" ''
......@@ -496,7 +492,7 @@ runTests() {
kube::test::describe_object_assert services 'redis-master' "Name:" "Labels:" "Selector:" "IP:" "Port:" "Endpoints:" "Session Affinity:"
### Dump current redis-master service
output_service=$(kubectl get service redis-master -o json --output-version=v1beta3 "${kube_flags[@]}")
output_service=$(kubectl get service redis-master -o json --output-version=v1 "${kube_flags[@]}")
### Delete redis-master-service by id
# Pre-condition: redis-master service is running
......@@ -776,11 +772,10 @@ __EOF__
kube_api_versions=(
""
v1beta3
v1
)
for version in "${kube_api_versions[@]}"; do
KUBE_API_VERSIONS="v1,v1beta3" runTests "${version}"
KUBE_API_VERSIONS="v1" runTests "${version}"
done
kube::log::status "TEST PASSED"
......@@ -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:-"v1,v1beta3"}
KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1"}
# 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}" KUBE_API_VERSIONS="v1,v1beta3" ETCD_PREFIX=${etcdPrefix} runTests "$@"
KUBE_API_VERSION="${apiVersion}" KUBE_API_VERSIONS="v1" ETCD_PREFIX=${etcdPrefix} runTests "$@"
i=${i}+1
j=${j}+1
if [[ i -eq ${apiVersionsCount} ]] && [[ j -eq ${etcdPrefixesCount} ]]; then
......
......@@ -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:-"v1,v1beta3"}
KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1"}
KUBE_INTEGRATION_TEST_MAX_CONCURRENCY=${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY:-"-1"}
LOG_LEVEL=${LOG_LEVEL:-2}
......@@ -43,18 +43,18 @@ runTests() {
KUBE_GOFLAGS="-tags 'integration no-docker' " \
KUBE_RACE="-race" \
KUBE_TEST_API_VERSIONS="$1" \
KUBE_API_VERSIONS="v1,v1beta3" \
KUBE_API_VERSIONS="v1" \
"${KUBE_ROOT}/hack/test-go.sh" test/integration
kube::log::status "Running integration test scenario"
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" \
KUBE_API_VERSIONS="v1" "${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" \
--max-concurrency="${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY}"
cleanup
}
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration
KUBE_API_VERSIONS="v1" "${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration
# Run cleanup to stop etcd on interrupt or other kill signal.
trap cleanup EXIT
......
......@@ -24,7 +24,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
# The api version in which objects are currently stored in etcd.
KUBE_OLD_API_VERSION=${KUBE_OLD_API_VERSION:-"v1beta3"}
KUBE_OLD_API_VERSION=${KUBE_OLD_API_VERSION:-"v1"}
# The api version in which our etcd objects should be converted to.
# The new api version
KUBE_NEW_API_VERSION=${KUBE_NEW_API_VERSION:-"v1"}
......
......@@ -53,7 +53,7 @@ EOF
mv $TMPFILE pkg/api/${version}/conversion_generated.go
}
VERSIONS="v1beta3 v1"
VERSIONS="v1"
for ver in $VERSIONS; do
# Ensure that the version being processed is registered by setting
# KUBE_API_VERSIONS.
......
......@@ -56,7 +56,7 @@ EOF
}
function generate_deep_copies() {
local versions="api v1beta3 v1"
local versions="api v1"
# To avoid compile errors, remove the currently existing files.
for ver in ${versions}; do
rm -f `result_file_name ${ver}`
......
......@@ -49,14 +49,14 @@ KUBELET_PORT=${KUBELET_PORT:-10250}
# Start kube-apiserver
kube::log::status "Starting kube-apiserver"
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
KUBE_API_VERSIONS="v1" "${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/v1beta3 \
--runtime_config=api/v1 \
--service-cluster-ip-range="10.0.0.0/24" >/dev/null 2>&1 &
APISERVER_PID=$!
......@@ -67,7 +67,6 @@ kube::log::status "Updating " ${SWAGGER_ROOT_DIR}
curl -fs ${SWAGGER_API_PATH} > ${SWAGGER_ROOT_DIR}/resourceListing.json
curl -fs ${SWAGGER_API_PATH}version > ${SWAGGER_ROOT_DIR}/version.json
curl -fs ${SWAGGER_API_PATH}api > ${SWAGGER_ROOT_DIR}/api.json
curl -fs ${SWAGGER_API_PATH}api/v1beta3 > ${SWAGGER_ROOT_DIR}/v1beta3.json
curl -fs ${SWAGGER_API_PATH}api/v1 > ${SWAGGER_ROOT_DIR}/v1.json
kube::log::status "SUCCESS"
......@@ -24,7 +24,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"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"
)
......@@ -128,12 +127,6 @@ func init() {
// string, or an error if the version is not known.
func InterfacesFor(version string) (*meta.VersionInterfaces, error) {
switch version {
case "v1beta3":
return &meta.VersionInterfaces{
Codec: v1beta3.Codec,
ObjectConvertor: api.Scheme,
MetadataAccessor: accessor,
}, nil
case "v1":
return &meta.VersionInterfaces{
Codec: v1.Codec,
......
......@@ -108,7 +108,6 @@ func TestKindToResource(t *testing.T) {
{Kind: "ReplicationController", MixedCase: true, Plural: "replicationControllers", Singular: "replicationController"},
{Kind: "ReplicationController", MixedCase: true, Plural: "replicationControllers", Singular: "replicationController"},
// API convention changed with regard to capitalization for v1beta3
{Kind: "ReplicationController", MixedCase: false, Plural: "replicationcontrollers", Singular: "replicationcontroller"},
{Kind: "ImageRepository", MixedCase: true, Plural: "imageRepositories", Singular: "imageRepository"},
......
......@@ -30,8 +30,7 @@ var RegisteredVersions []string
func init() {
validAPIVersions := map[string]bool{
"v1": true,
"v1beta3": true,
"v1": true,
}
// The default list of supported api versions, in order of most preferred to the least.
......
......@@ -99,9 +99,8 @@ func ResourcePathWithPrefix(prefix, resource, namespace, name string) string {
}
// Returns the appropriate path for the given resource, namespace and name.
// For ex, this is of the form:
// /api/v1beta1/pods/pod0 for v1beta1 and
// /api/v1beta3/namespaces/foo/pods/pod0 for v1beta3.
// For example, this is of the form:
// /api/v1/namespaces/foo/pods/pod0 for v1.
func ResourcePath(resource, namespace, name string) string {
return ResourcePathWithPrefix("", resource, namespace, name)
}
......@@ -31,8 +31,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
docker "github.com/fsouza/go-dockerclient"
"github.com/google/gofuzz"
"github.com/google/gofuzz"
"speter.net/go/exp/math/dec/inf"
)
......
......@@ -806,11 +806,10 @@ type ContainerStatus struct {
Ready bool `json:"ready"`
// Note that this is calculated from dead containers. But those containers are subject to
// garbage collection. This value will get capped at 5 by GC.
RestartCount int `json:"restartCount"`
// TODO(dchen1107): Need to decide how to represent this in v1beta3
Image string `json:"image"`
ImageID string `json:"imageID"`
ContainerID string `json:"containerID,omitempty"`
RestartCount int `json:"restartCount"`
Image string `json:"image"`
ImageID string `json:"imageID"`
ContainerID string `json:"containerID,omitempty"`
}
// PodPhase is a label for the condition of a pod at the current time.
......@@ -1009,7 +1008,7 @@ type ReplicationControllerSpec struct {
// TemplateRef is a reference to an object that describes the pod that will be created if
// insufficient replicas are detected. This reference is ignored if a Template is set.
// Must be set before converting to a v1beta3 API object
// Must be set before converting to a versioned API object
//TemplateRef *ObjectReference `json:"templateRef,omitempty"`
// Template is the object that describes the pod that will be created if
......@@ -1163,10 +1162,8 @@ type ServicePort struct {
// Optional: The target port on pods selected by this service. If this
// is a string, it will be looked up as a named port in the target
// Pod's container ports. If this is not specified, the first port on
// the destination pod will be used. This behavior is deprecated. As
// of v1beta3 the default value is the sames as the Port field (an
// identity map).
// Pod's container ports. If this is not specified, the default value
// is the sames as the Port field (an identity map).
TargetPort util.IntOrString `json:"targetPort"`
// The port on each node on which this service is exposed.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta3_test
import (
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
versioned "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
)
func TestResourceQuotaStatusConversion(t *testing.T) {
// should serialize as "0"
expected := resource.NewQuantity(int64(0), resource.DecimalSI)
if "0" != expected.String() {
t.Errorf("Expected: 0, Actual: %v, do not require units", expected.String())
}
parsed := resource.MustParse("0")
if "0" != parsed.String() {
t.Errorf("Expected: 0, Actual: %v, do not require units", parsed.String())
}
quota := &api.ResourceQuota{}
quota.Status = api.ResourceQuotaStatus{}
quota.Status.Hard = api.ResourceList{}
quota.Status.Used = api.ResourceList{}
quota.Status.Hard[api.ResourcePods] = *expected
// round-trip the object
data, _ := versioned.Codec.Encode(quota)
object, _ := versioned.Codec.Decode(data)
after := object.(*api.ResourceQuota)
actualQuantity := after.Status.Hard[api.ResourcePods]
actual := &actualQuantity
// should be "0", but was "0m"
if expected.String() != actual.String() {
t.Errorf("Expected %v, Actual %v", expected.String(), actual.String())
}
}
func TestNodeConversion(t *testing.T) {
obj, err := versioned.Codec.Decode([]byte(`{"kind":"Minion","apiVersion":"v1beta3"}`))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*api.Node); !ok {
t.Errorf("unexpected type: %#v", obj)
}
obj, err = versioned.Codec.Decode([]byte(`{"kind":"MinionList","apiVersion":"v1beta3"}`))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*api.NodeList); !ok {
t.Errorf("unexpected type: %#v", obj)
}
obj = &api.Node{}
if err := versioned.Codec.DecodeInto([]byte(`{"kind":"Minion","apiVersion":"v1beta3"}`), obj); err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
func TestBadSecurityContextConversion(t *testing.T) {
priv := false
testCases := map[string]struct {
c *versioned.Container
err string
}{
// 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": {
c: &versioned.Container{
Privileged: true,
SecurityContext: &versioned.SecurityContext{
Privileged: &priv,
},
},
err: "container privileged settings do not match security context settings, cannot convert",
},
"mismatched caps add": {
c: &versioned.Container{
Capabilities: versioned.Capabilities{
Add: []versioned.Capability{"foo"},
},
SecurityContext: &versioned.SecurityContext{
Capabilities: &versioned.Capabilities{
Add: []versioned.Capability{"bar"},
},
},
},
err: "container capability settings do not match security context settings, cannot convert",
},
"mismatched caps drop": {
c: &versioned.Container{
Capabilities: versioned.Capabilities{
Drop: []versioned.Capability{"foo"},
},
SecurityContext: &versioned.SecurityContext{
Capabilities: &versioned.Capabilities{
Drop: []versioned.Capability{"bar"},
},
},
},
err: "container capability settings do not match security context settings, cannot convert",
},
}
for k, v := range testCases {
got := api.Container{}
err := api.Scheme.Convert(v.c, &got)
if err == nil {
t.Errorf("expected error for case %s but got none", k)
} else {
if err.Error() != v.err {
t.Errorf("unexpected error for case %s. Expected: %s but got: %s", k, v.err, err.Error())
}
}
}
}
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta3
import (
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
)
func addDefaultingFuncs() {
api.Scheme.AddDefaultingFuncs(
func(obj *ReplicationController) {
var labels map[string]string
if obj.Spec.Template != nil {
labels = obj.Spec.Template.Labels
}
// TODO: support templates defined elsewhere when we support them in the API
if labels != nil {
if len(obj.Spec.Selector) == 0 {
obj.Spec.Selector = labels
}
if len(obj.Labels) == 0 {
obj.Labels = labels
}
}
if obj.Spec.Replicas == nil {
obj.Spec.Replicas = new(int)
*obj.Spec.Replicas = 0
}
},
func(obj *Volume) {
if util.AllPtrFieldsNil(&obj.VolumeSource) {
obj.VolumeSource = VolumeSource{
EmptyDir: &EmptyDirVolumeSource{},
}
}
},
func(obj *ContainerPort) {
if obj.Protocol == "" {
obj.Protocol = ProtocolTCP
}
},
func(obj *Container) {
if obj.ImagePullPolicy == "" {
// TODO(dchen1107): Move ParseImageName code to pkg/util
parts := strings.Split(obj.Image, ":")
// Check image tag
if parts[len(parts)-1] == "latest" {
obj.ImagePullPolicy = PullAlways
} else {
obj.ImagePullPolicy = PullIfNotPresent
}
}
if obj.TerminationMessagePath == "" {
obj.TerminationMessagePath = TerminationMessagePathDefault
}
defaultSecurityContext(obj)
},
func(obj *ServiceSpec) {
if obj.SessionAffinity == "" {
obj.SessionAffinity = ServiceAffinityNone
}
if obj.Type == "" {
if obj.CreateExternalLoadBalancer {
obj.Type = ServiceTypeLoadBalancer
} else {
obj.Type = ServiceTypeClusterIP
}
} else if obj.Type == ServiceTypeLoadBalancer {
obj.CreateExternalLoadBalancer = true
}
for i := range obj.Ports {
sp := &obj.Ports[i]
if sp.Protocol == "" {
sp.Protocol = ProtocolTCP
}
if sp.TargetPort == util.NewIntOrStringFromInt(0) || sp.TargetPort == util.NewIntOrStringFromString("") {
sp.TargetPort = util.NewIntOrStringFromInt(sp.Port)
}
}
},
func(obj *PodSpec) {
if obj.DNSPolicy == "" {
obj.DNSPolicy = DNSClusterFirst
}
if obj.RestartPolicy == "" {
obj.RestartPolicy = RestartPolicyAlways
}
if obj.HostNetwork {
defaultHostNetworkPorts(&obj.Containers)
}
},
func(obj *Probe) {
if obj.TimeoutSeconds == 0 {
obj.TimeoutSeconds = 1
}
},
func(obj *Secret) {
if obj.Type == "" {
obj.Type = SecretTypeOpaque
}
},
func(obj *PersistentVolume) {
if obj.Status.Phase == "" {
obj.Status.Phase = VolumePending
}
if obj.Spec.PersistentVolumeReclaimPolicy == "" {
obj.Spec.PersistentVolumeReclaimPolicy = PersistentVolumeReclaimRetain
}
},
func(obj *PersistentVolumeClaim) {
if obj.Status.Phase == "" {
obj.Status.Phase = ClaimPending
}
},
func(obj *Endpoints) {
for i := range obj.Subsets {
ss := &obj.Subsets[i]
for i := range ss.Ports {
ep := &ss.Ports[i]
if ep.Protocol == "" {
ep.Protocol = ProtocolTCP
}
}
}
},
func(obj *HTTPGetAction) {
if obj.Path == "" {
obj.Path = "/"
}
if obj.Scheme == "" {
obj.Scheme = URISchemeHTTP
}
},
func(obj *NamespaceStatus) {
if obj.Phase == "" {
obj.Phase = NamespaceActive
}
},
func(obj *Node) {
if obj.Spec.ExternalID == "" {
obj.Spec.ExternalID = obj.Name
}
},
func(obj *ObjectFieldSelector) {
if obj.APIVersion == "" {
obj.APIVersion = "v1beta3"
}
},
)
}
// With host networking default all container ports to host ports.
func defaultHostNetworkPorts(containers *[]Container) {
for i := range *containers {
for j := range (*containers)[i].Ports {
if (*containers)[i].Ports[j].HostPort == 0 {
(*containers)[i].Ports[j].HostPort = (*containers)[i].Ports[j].ContainerPort
}
}
}
}
// defaultSecurityContext performs the downward and upward merges of a pod definition
func defaultSecurityContext(container *Container) {
if container.SecurityContext == nil {
if (len(container.Capabilities.Add) == 0) && (len(container.Capabilities.Drop) == 0) && (container.Privileged == false) {
return
}
glog.V(5).Infof("creating security context for container %s", container.Name)
container.SecurityContext = &SecurityContext{}
}
// if there are no capabilities defined on the SecurityContext then copy the container settings
if container.SecurityContext.Capabilities == nil {
container.SecurityContext.Capabilities = &container.Capabilities
} else {
// if there are capabilities defined on the security context and the container setting is
// empty then assume that it was left off the pod definition and ensure that the container
// settings match the security context settings (checked by the convert functions). If
// there are settings in both then don't touch it, the converter will error if they don't
// match
if len(container.Capabilities.Add) == 0 {
container.Capabilities.Add = container.SecurityContext.Capabilities.Add
}
if len(container.Capabilities.Drop) == 0 {
container.Capabilities.Drop = container.SecurityContext.Capabilities.Drop
}
}
// if there are no privileged settings on the security context then copy the container settings
if container.SecurityContext.Privileged == nil {
container.SecurityContext.Privileged = &container.Privileged
} else {
// we don't have a good way to know if container.Privileged was set or just defaulted to false
// so the best we can do here is check if the securityContext is set to true and the
// container is set to false and assume that the Privileged field was left off the container
// definition and not an intentional mismatch
if *container.SecurityContext.Privileged && !container.Privileged {
container.Privileged = *container.SecurityContext.Privileged
}
}
}
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package v1beta3 is the v1beta3 version of the API.
package v1beta3
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta3
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
// Codec encodes internal objects to the v1beta3 scheme
var Codec = runtime.CodecFor(api.Scheme, "v1beta3")
func init() {
// Check if v1beta3 is in the list of supported API versions.
if !registered.IsRegisteredAPIVersion("v1beta3") {
return
}
// Register the API.
addKnownTypes()
addConversionFuncs()
addDefaultingFuncs()
}
// Adds the list of known types to api.Scheme.
func addKnownTypes() {
api.Scheme.AddKnownTypes("v1beta3",
&Pod{},
&PodList{},
&PodStatusResult{},
&PodTemplate{},
&PodTemplateList{},
&ReplicationController{},
&ReplicationControllerList{},
&Service{},
&ServiceList{},
&Endpoints{},
&EndpointsList{},
&Node{},
&NodeList{},
&Binding{},
&Status{},
&Event{},
&EventList{},
&List{},
&LimitRange{},
&LimitRangeList{},
&ResourceQuota{},
&ResourceQuotaList{},
&Namespace{},
&NamespaceList{},
&Secret{},
&SecretList{},
&ServiceAccount{},
&ServiceAccountList{},
&PersistentVolume{},
&PersistentVolumeList{},
&PersistentVolumeClaim{},
&PersistentVolumeClaimList{},
&DeleteOptions{},
&ListOptions{},
&PodLogOptions{},
&PodExecOptions{},
&PodProxyOptions{},
&ComponentStatus{},
&ComponentStatusList{},
&SerializedReference{},
&RangeAllocation{},
)
// Legacy names are supported
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
api.Scheme.AddKnownTypeWithName("v1beta3", "MinionList", &NodeList{})
}
func (*Pod) IsAnAPIObject() {}
func (*PodList) IsAnAPIObject() {}
func (*PodStatusResult) IsAnAPIObject() {}
func (*PodTemplate) IsAnAPIObject() {}
func (*PodTemplateList) IsAnAPIObject() {}
func (*ReplicationController) IsAnAPIObject() {}
func (*ReplicationControllerList) IsAnAPIObject() {}
func (*Service) IsAnAPIObject() {}
func (*ServiceList) IsAnAPIObject() {}
func (*Endpoints) IsAnAPIObject() {}
func (*EndpointsList) IsAnAPIObject() {}
func (*Node) IsAnAPIObject() {}
func (*NodeList) IsAnAPIObject() {}
func (*Binding) IsAnAPIObject() {}
func (*Status) IsAnAPIObject() {}
func (*Event) IsAnAPIObject() {}
func (*EventList) IsAnAPIObject() {}
func (*List) IsAnAPIObject() {}
func (*LimitRange) IsAnAPIObject() {}
func (*LimitRangeList) IsAnAPIObject() {}
func (*ResourceQuota) IsAnAPIObject() {}
func (*ResourceQuotaList) IsAnAPIObject() {}
func (*Namespace) IsAnAPIObject() {}
func (*NamespaceList) IsAnAPIObject() {}
func (*Secret) IsAnAPIObject() {}
func (*SecretList) IsAnAPIObject() {}
func (*ServiceAccount) IsAnAPIObject() {}
func (*ServiceAccountList) IsAnAPIObject() {}
func (*PersistentVolume) IsAnAPIObject() {}
func (*PersistentVolumeList) IsAnAPIObject() {}
func (*PersistentVolumeClaim) IsAnAPIObject() {}
func (*PersistentVolumeClaimList) IsAnAPIObject() {}
func (*DeleteOptions) IsAnAPIObject() {}
func (*ListOptions) IsAnAPIObject() {}
func (*PodLogOptions) IsAnAPIObject() {}
func (*PodExecOptions) IsAnAPIObject() {}
func (*PodProxyOptions) IsAnAPIObject() {}
func (*ComponentStatus) IsAnAPIObject() {}
func (*ComponentStatusList) IsAnAPIObject() {}
func (*SerializedReference) IsAnAPIObject() {}
func (*RangeAllocation) IsAnAPIObject() {}
This source diff could not be displayed because it is too large. You can view the blob instead.
apiVersion: v1beta3
kind: Pod
metadata:
labels:
name: redis-master
name: name
spec:
containers:
- args: "this is a bad command"
image: redis
name: master
{
"kind": "Pod",
"apiVersion": "v1beta3",
"metadata": {
"name": "name",
"labels": {
"name": "redis-master"
}
},
"spec": {
"containers": [
{
"name": "master",
"image": "redis",
"args": "this is a bad command"
}
]
}
}
{
"kind": "Pod",
"apiVersion": "v1beta3",
"metadata": {
"name": "apache-php",
"labels": {
"name": "apache-php"
}
},
"spec": {
"volumes": [{
"name": "shared-disk"
}],
"containers": [
{
"name": "apache-php",
"image": "php:5.6.2-apache",
"ports": [
{
"name": "apache",
"hostPort": "13380",
"containerPort": 80,
"protocol": "TCP"
}
],
"volumeMounts": [
{
"name": "shared-disk",
"mountPath": "/var/www/html"
}
]
}
]
}
}
{
"kind": "Pod",
"apiVersion": "v1beta3",
"metadata": {
"name": "apache-php",
"labels": {
"name": "apache-php"
}
},
"spec": {
"volumes": [
"name": "shared-disk"
],
"containers": [
{
"name": "apache-php",
"image": "php:5.6.2-apache",
"ports": [
{
"name": "apache",
"hostPort": 13380,
"containerPort": 80,
"protocol": "TCP"
}
],
"volumeMounts": [
{
"name": "shared-disk",
"mountPath": "/var/www/html"
}
]
}
]
}
}
apiVersion: v1beta3
kind: Pod
metadata:
labels:
name: redis-master
name: name
spec:
containers:
- args:
- this
- is
- an
- ok
- command
image: redis
name: master
......@@ -81,7 +81,7 @@ type APIGroupVersion struct {
// ServerVersion controls the Kubernetes APIVersion used for common objects in the apiserver
// schema like api.Status, api.DeleteOptions, and api.ListOptions. Other implementors may
// define a version "v1beta1" but want to use the Kubernetes "v1beta3" internal objects. If
// define a version "v1beta1" but want to use the Kubernetes "v1" internal objects. If
// empty, defaults to Version.
ServerVersion string
......
......@@ -177,7 +177,7 @@ func handle(storage map[string]rest.Storage) http.Handler {
return handleInternal(true, storage, admissionControl, selfLinker)
}
// uses the default settings for a v1beta3 compatible api
// uses the default settings for a v1 compatible api
func handleNew(storage map[string]rest.Storage) http.Handler {
return handleInternal(false, storage, admissionControl, selfLinker)
}
......
......@@ -56,7 +56,7 @@ type Cluster struct {
LocationOfOrigin string
// Server is the address of the kubernetes cluster (https://hostname:port).
Server string `json:"server"`
// APIVersion is the preferred api version for communicating with the kubernetes cluster (v1beta1, v1beta2, v1beta3, etc).
// APIVersion is the preferred api version for communicating with the kubernetes cluster (v1, v2, etc).
APIVersion string `json:"api-version,omitempty"`
// InsecureSkipTLSVerify skips the validity check for the server's certificate. This will make your HTTPS connections insecure.
InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify,omitempty"`
......
......@@ -54,7 +54,7 @@ type Preferences struct {
type Cluster struct {
// Server is the address of the kubernetes cluster (https://hostname:port).
Server string `json:"server"`
// APIVersion is the preferred api version for communicating with the kubernetes cluster (v1beta1, v1beta2, v1beta3, etc).
// APIVersion is the preferred api version for communicating with the kubernetes cluster (v1, v2, etc).
APIVersion string `json:"api-version,omitempty"`
// InsecureSkipTLSVerify skips the validity check for the server's certificate. This will make your HTTPS connections insecure.
InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify,omitempty"`
......
......@@ -312,40 +312,6 @@ func (v versionToResourceToFieldMapping) filterField(apiVersion, resourceType, f
}
var fieldMappings = versionToResourceToFieldMapping{
"v1beta3": resourceTypeToFieldMapping{
"nodes": clientFieldNameToAPIVersionFieldName{
ObjectNameField: "metadata.name",
NodeUnschedulable: "spec.unschedulable",
},
"minions": clientFieldNameToAPIVersionFieldName{
ObjectNameField: "metadata.name",
NodeUnschedulable: "spec.unschedulable",
},
"pods": clientFieldNameToAPIVersionFieldName{
PodHost: "spec.host",
},
"secrets": clientFieldNameToAPIVersionFieldName{
SecretType: "type",
},
"serviceAccounts": clientFieldNameToAPIVersionFieldName{
ObjectNameField: "metadata.name",
},
"endpoints": clientFieldNameToAPIVersionFieldName{
ObjectNameField: "metadata.name",
},
"events": clientFieldNameToAPIVersionFieldName{
ObjectNameField: "metadata.name",
EventReason: "reason",
EventSource: "source",
EventInvolvedKind: "involvedObject.kind",
EventInvolvedNamespace: "involvedObject.namespace",
EventInvolvedName: "involvedObject.name",
EventInvolvedUID: "involvedObject.uid",
EventInvolvedAPIVersion: "involvedObject.apiVersion",
EventInvolvedResourceVersion: "involvedObject.resourceVersion",
EventInvolvedFieldPath: "involvedObject.fieldPath",
},
},
"v1": resourceTypeToFieldMapping{
"nodes": clientFieldNameToAPIVersionFieldName{
ObjectNameField: "metadata.name",
......
......@@ -1049,13 +1049,6 @@ func TestUnversionedPath(t *testing.T) {
t.Errorf("test case %d failed: unexpected path: %s, expected %s", i+1, r.path, tc.expectedPath)
}
}
for i, tc := range tt {
c := NewOrDie(&Config{Host: tc.host, Prefix: tc.prefix, Version: "v1beta3"})
r := c.Post().Prefix("/alpha").UnversionedPath(tc.unversioned)
if r.path != tc.expectedPath {
t.Errorf("test case %d failed: unexpected path: %s, expected %s", i+1, r.path, tc.expectedPath)
}
}
}
func TestAbsPath(t *testing.T) {
......
......@@ -238,7 +238,7 @@ func TestGetSchemaObject(t *testing.T) {
Resp: &http.Response{StatusCode: 200, Body: objBody(codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}})},
}
tf.Namespace = "test"
tf.ClientConfig = &client.Config{Version: "v1beta3"}
tf.ClientConfig = &client.Config{Version: "v1"}
buf := bytes.NewBuffer([]byte{})
cmd := NewCmdGet(f, buf)
......
......@@ -150,19 +150,11 @@ func TestSelectContainer(t *testing.T) {
}
func TestLog(t *testing.T) {
tests := []struct {
name, version, podPath, logPath, container string
pod *api.Pod
}{
{
name: "v1beta3 - pod log",
version: "v1beta3",
podPath: "/api/v1beta3/namespaces/test/pods/foo",
logPath: "/api/v1beta3/namespaces/test/pods/foo/log",
pod: testPod(),
},
{
name: "v1 - pod log",
version: "v1",
podPath: "/api/v1/namespaces/test/pods/foo",
......
......@@ -27,7 +27,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource"
......@@ -304,10 +303,6 @@ func isReplicasDefaulted(info *resource.Info) bool {
if rc, ok := info.VersionedObject.(*v1.ReplicationController); ok {
return rc.Spec.Replicas == nil
}
case "v1beta3":
if rc, ok := info.VersionedObject.(*v1beta3.ReplicationController); ok {
return rc.Spec.Replicas == nil
}
}
return false
}
......@@ -38,7 +38,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authenticator"
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authorizer"
......@@ -98,8 +97,6 @@ type Config struct {
EnableUISupport bool
// allow downstream consumers to disable swagger
EnableSwaggerSupport bool
// allow v1beta3 to be conditionally enabled
EnableV1Beta3 bool
// allow v1 to be conditionally disabled
DisableV1 bool
// allow downstream consumers to disable the index route
......@@ -187,7 +184,6 @@ type Master struct {
authorizer authorizer.Authorizer
admissionControl admission.Interface
masterCount int
v1beta3 bool
v1 bool
requestContextMapper api.RequestContextMapper
......@@ -343,7 +339,6 @@ func New(c *Config) *Master {
authenticator: c.Authenticator,
authorizer: c.Authorizer,
admissionControl: c.AdmissionControl,
v1beta3: c.EnableV1Beta3,
v1: !c.DisableV1,
requestContextMapper: c.RequestContextMapper,
......@@ -556,12 +551,6 @@ func (m *Master) init(c *Config) {
}
apiVersions := []string{}
if m.v1beta3 {
if err := m.api_v1beta3().InstallREST(m.handlerContainer); err != nil {
glog.Fatalf("Unable to setup API v1beta3: %v", err)
}
apiVersions = append(apiVersions, "v1beta3")
}
if m.v1 {
if err := m.api_v1().InstallREST(m.handlerContainer); err != nil {
glog.Fatalf("Unable to setup API v1: %v", err)
......@@ -756,19 +745,6 @@ func (m *Master) defaultAPIGroupVersion() *apiserver.APIGroupVersion {
}
}
// api_v1beta3 returns the resources and codec for API version v1beta3.
func (m *Master) api_v1beta3() *apiserver.APIGroupVersion {
storage := make(map[string]rest.Storage)
for k, v := range m.storage {
storage[strings.ToLower(k)] = v
}
version := m.defaultAPIGroupVersion()
version.Storage = storage
version.Version = "v1beta3"
version.Codec = v1beta3.Codec
return version
}
// api_v1 returns the resources and codec for API version v1.
func (m *Master) api_v1() *apiserver.APIGroupVersion {
storage := make(map[string]rest.Storage)
......
......@@ -28,7 +28,6 @@ import (
"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"
"github.com/golang/glog"
......
......@@ -27,7 +27,6 @@ import (
"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"
"github.com/golang/glog"
......
......@@ -20,7 +20,6 @@ import (
"fmt"
"io"
"math/rand"
"strings"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
......@@ -176,9 +175,7 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli
obj := a.GetObject()
// handle max counts for each kind of resource (pods, services, replicationControllers, etc.)
if a.GetOperation() == admission.Create {
// TODO v1beta1 had camel case, v1beta3 went to all lower, we can remove this line when we deprecate v1beta1
resourceNormalized := strings.ToLower(a.GetResource())
resourceName := resourceToResourceName[resourceNormalized]
resourceName := resourceToResourceName[a.GetResource()]
hard, hardFound := status.Hard[resourceName]
if hardFound {
used, usedFound := status.Used[resourceName]
......
......@@ -423,7 +423,7 @@ func TestIncrementUsageReplicationControllers(t *testing.T) {
r := api.ResourceReplicationControllers
status.Hard[r] = resource.MustParse("2")
status.Used[r] = resource.MustParse("1")
dirty, err := IncrementUsage(admission.NewAttributesRecord(&api.ReplicationController{}, "ReplicationController", namespace, "name", "replicationControllers", "", admission.Create, nil), status, client)
dirty, err := IncrementUsage(admission.NewAttributesRecord(&api.ReplicationController{}, "ReplicationController", namespace, "name", "replicationcontrollers", "", admission.Create, nil), status, client)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
......@@ -452,7 +452,7 @@ func TestExceedUsageReplicationControllers(t *testing.T) {
r := api.ResourceReplicationControllers
status.Hard[r] = resource.MustParse("1")
status.Used[r] = resource.MustParse("1")
_, err := IncrementUsage(admission.NewAttributesRecord(&api.ReplicationController{}, "ReplicationController", namespace, "name", "replicationControllers", "", admission.Create, nil), status, client)
_, err := IncrementUsage(admission.NewAttributesRecord(&api.ReplicationController{}, "ReplicationController", namespace, "name", "replicationcontrollers", "", admission.Create, nil), status, client)
if err == nil {
t.Errorf("Expected error for exceeding hard limits")
}
......@@ -496,7 +496,7 @@ func TestExceedUsagePersistentVolumeClaims(t *testing.T) {
r := api.ResourcePersistentVolumeClaims
status.Hard[r] = resource.MustParse("1")
status.Used[r] = resource.MustParse("1")
_, err := IncrementUsage(admission.NewAttributesRecord(&api.PersistentVolumeClaim{}, "PersistentVolumeClaim", namespace, "name", "persistentVolumeClaims", "", admission.Create, nil), status, client)
_, err := IncrementUsage(admission.NewAttributesRecord(&api.PersistentVolumeClaim{}, "PersistentVolumeClaim", namespace, "name", "persistentvolumeclaims", "", admission.Create, nil), status, client)
if err == nil {
t.Errorf("Expected error for exceeding hard limits")
}
......
......@@ -17,11 +17,11 @@ limitations under the License.
package v1
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
apiv1 "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
)
type Policy struct {
v1beta3.TypeMeta `json:",inline"`
apiv1.TypeMeta `json:",inline"`
// Holds the information to configure the fit predicate functions
Predicates []PredicatePolicy `json:"predicates"`
// Holds the information to configure the priority functions
......
......@@ -11,7 +11,7 @@ matrix:
- KUBE_TEST_API_VERSIONS=v1 KUBE_TEST_ETCD_PREFIXES=registry
- go: 1.3
env:
- KUBE_TEST_API_VERSIONS=v1beta3 KUBE_TEST_ETCD_PREFIXES=kubernetes.io/registry
- KUBE_TEST_API_VERSIONS=v1 KUBE_TEST_ETCD_PREFIXES=kubernetes.io/registry
before_install:
- source $HOME/.gvm/scripts/gvm;
......
......@@ -393,10 +393,8 @@ func TestAuthModeAlwaysAllow(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
})
transport := http.DefaultTransport
......@@ -511,10 +509,8 @@ func TestAuthModeAlwaysDeny(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysDenyAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysDenyAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
})
transport := http.DefaultTransport
......@@ -580,11 +576,9 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(),
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(),
})
previousResourceVersion := make(map[string]float64)
......@@ -669,11 +663,9 @@ func TestBobIsForbidden(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(),
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(),
})
transport := http.DefaultTransport
......@@ -732,11 +724,9 @@ func TestUnknownUserIsUnauthorized(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(),
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(),
})
transport := http.DefaultTransport
......@@ -814,11 +804,9 @@ func TestNamespaceAuthorization(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(),
Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(),
Authenticator: getTestTokenAuth(),
Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(),
})
previousResourceVersion := make(map[string]float64)
......@@ -931,11 +919,9 @@ func TestKindAuthorization(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(),
Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(),
Authenticator: getTestTokenAuth(),
Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(),
})
previousResourceVersion := make(map[string]float64)
......@@ -1035,11 +1021,9 @@ func TestReadOnlyAuthorization(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(),
Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(),
Authenticator: getTestTokenAuth(),
Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(),
})
transport := http.DefaultTransport
......
......@@ -139,10 +139,8 @@ func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Se
EnableProfiling: true,
EnableUISupport: false,
APIPrefix: "/api",
// Enable v1bewta3 if we are testing that version
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
}
} else {
helper = masterConfig.EtcdHelper
......@@ -272,10 +270,8 @@ func RunAMaster(t *testing.T) (*master.Master, *httptest.Server) {
EnableProfiling: true,
EnableUISupport: false,
APIPrefix: "/api",
// Enable v1bewta3 if we are testing that version
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
})
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
......
......@@ -73,10 +73,8 @@ func TestUnschedulableNodes(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
})
restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: testapi.Version()})
......
......@@ -66,10 +66,8 @@ func TestSecrets(t *testing.T) {
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
})
framework.DeleteAllEtcdKeys()
......
......@@ -416,11 +416,9 @@ func startServiceAccountTestServer(t *testing.T) (*client.Client, client.Config,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: authenticator,
Authorizer: authorizer,
AdmissionControl: serviceAccountAdmission,
Authenticator: authenticator,
Authorizer: authorizer,
AdmissionControl: serviceAccountAdmission,
})
// Start the service account and service account token controllers
......
......@@ -80,10 +80,8 @@ func runAMaster(t *testing.T) (*master.Master, *httptest.Server) {
EnableProfiling: true,
EnableUISupport: false,
APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
})
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment