diff --git a/cn/docs/concepts/workloads/controllers/garbage-collection.md b/cn/docs/concepts/workloads/controllers/garbage-collection.md index 1d8a921490..c9af3905b7 100644 --- a/cn/docs/concepts/workloads/controllers/garbage-collection.md +++ b/cn/docs/concepts/workloads/controllers/garbage-collection.md @@ -45,7 +45,7 @@ Kubernetes 垃圾收集器的角色是删除指定的对象,这些对象曾经 如果创建该 ReplicaSet,然后查看 Pod 的 metadata 字段,能够看到 OwnerReferences 字段: ```shell -kubectl create -f https://k8s.io/docs/concepts/abstractions/controllers/my-repset.yaml +kubectl create -f https://k8s.io/docs/concepts/controllers/my-repset.yaml kubectl get pods --output=yaml ``` diff --git a/docs/admin/daemon.yaml b/docs/admin/daemon.yaml deleted file mode 100644 index c5cd14a592..0000000000 --- a/docs/admin/daemon.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: extensions/v1beta1 -kind: DaemonSet -metadata: - name: prometheus-node-exporter -spec: - template: - metadata: - name: prometheus-node-exporter - labels: - daemon: prom-node-exp - spec: - containers: - - name: c - image: prom/prometheus - ports: - - containerPort: 9090 - hostPort: 9090 - name: serverport diff --git a/docs/admin/high-availability/kube-scheduler.yaml b/docs/admin/high-availability/kube-scheduler.yaml index 9e997cbc47..40c863da48 100644 --- a/docs/admin/high-availability/kube-scheduler.yaml +++ b/docs/admin/high-availability/kube-scheduler.yaml @@ -21,9 +21,6 @@ spec: volumeMounts: - mountPath: /var/log/kube-scheduler.log name: logfile - - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - name: default-token-s8ejd - readOnly: true volumes: - hostPath: path: /var/log/kube-scheduler.log diff --git a/docs/admin/multiple-schedulers/pod1.yaml b/docs/admin/multiple-schedulers/pod1.yaml index 733aa97d99..6cf8fec25a 100644 --- a/docs/admin/multiple-schedulers/pod1.yaml +++ b/docs/admin/multiple-schedulers/pod1.yaml @@ -7,4 +7,4 @@ metadata: spec: containers: - name: pod-with-no-annotation-container - image: gcr.io/google_containers/pause:2.0 \ No newline at end of file + image: gcr.io/google_containers/pause:2.0 diff --git a/docs/concepts/abstractions/controllers/my-repset.yaml b/docs/concepts/abstractions/controllers/my-repset.yaml deleted file mode 100644 index 54befd8f9d..0000000000 --- a/docs/concepts/abstractions/controllers/my-repset.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: extensions/v1beta1 -kind: ReplicaSet -metadata: - name: my-repset -spec: - replicas: 3 - selector: - matchLabels: - pod-is-for: garbage-collection-example - template: - metadata: - labels: - pod-is-for: garbage-collection-example - spec: - containers: - - name: nginx - image: nginx diff --git a/docs/concepts/abstractions/nginx-deployment.yaml b/docs/concepts/abstractions/nginx-deployment.yaml deleted file mode 100644 index 2aabf5e7b1..0000000000 --- a/docs/concepts/abstractions/nginx-deployment.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: apps/v1beta1 -kind: Deployment -metadata: - name: nginx-deployment -spec: - replicas: 3 - template: - metadata: - labels: - app: nginx - spec: - containers: - - name: nginx - image: nginx:1.7.9 - ports: - - containerPort: 80 diff --git a/docs/concepts/overview/working-with-objects/nginx-deployment.yaml b/docs/concepts/overview/working-with-objects/nginx-deployment.yaml index 8925d1b08d..4139bd1ac1 100644 --- a/docs/concepts/overview/working-with-objects/nginx-deployment.yaml +++ b/docs/concepts/overview/working-with-objects/nginx-deployment.yaml @@ -4,6 +4,9 @@ metadata: name: nginx-deployment spec: replicas: 3 + selector: + matchLabels: + app: nginx template: metadata: labels: diff --git a/docs/concepts/workloads/controllers/garbage-collection.md b/docs/concepts/workloads/controllers/garbage-collection.md index b220a17cdd..2f83cc87ab 100644 --- a/docs/concepts/workloads/controllers/garbage-collection.md +++ b/docs/concepts/workloads/controllers/garbage-collection.md @@ -40,7 +40,7 @@ If you create the ReplicaSet and then view the Pod metadata, you can see OwnerReferences field: ```shell -kubectl create -f https://k8s.io/docs/concepts/abstractions/controllers/my-repset.yaml +kubectl create -f https://k8s.io/docs/concepts/controllers/my-repset.yaml kubectl get pods --output=yaml ``` diff --git a/test/examples_test.go b/test/examples_test.go index be88ff908f..87b7e9a54a 100644 --- a/test/examples_test.go +++ b/test/examples_test.go @@ -32,15 +32,17 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/yaml" - api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/core/validation" "k8s.io/kubernetes/pkg/apis/apps" apps_validation "k8s.io/kubernetes/pkg/apis/apps/validation" + "k8s.io/kubernetes/pkg/apis/autoscaling" + autoscaling_validation "k8s.io/kubernetes/pkg/apis/autoscaling/validation" "k8s.io/kubernetes/pkg/apis/batch" batch_validation "k8s.io/kubernetes/pkg/apis/batch/validation" + api "k8s.io/kubernetes/pkg/apis/core" + "k8s.io/kubernetes/pkg/apis/core/validation" "k8s.io/kubernetes/pkg/apis/extensions" - expvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation" + ext_validation "k8s.io/kubernetes/pkg/apis/extensions/validation" "k8s.io/kubernetes/pkg/apis/policy" policyvalidation "k8s.io/kubernetes/pkg/apis/policy/validation" "k8s.io/kubernetes/pkg/apis/storage" @@ -113,11 +115,21 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) { t.Namespace = api.NamespaceDefault } errors = validation.ValidateResourceQuota(t) + case *autoscaling.HorizontalPodAutoscaler: + if t.Namespace == "" { + t.Namespace = api.NamespaceDefault + } + errors = autoscaling_validation.ValidateHorizontalPodAutoscaler(t) case *extensions.Deployment: if t.Namespace == "" { t.Namespace = api.NamespaceDefault } - errors = expvalidation.ValidateDeployment(t) + errors = ext_validation.ValidateDeployment(t) + case *extensions.ReplicaSet: + if t.Namespace == "" { + t.Namespace = api.NamespaceDefault + } + errors = ext_validation.ValidateReplicaSet(t) case *batch.Job: if t.Namespace == "" { t.Namespace = api.NamespaceDefault @@ -130,14 +142,14 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) { if t.Namespace == "" { t.Namespace = api.NamespaceDefault } - errors = expvalidation.ValidateIngress(t) + errors = ext_validation.ValidateIngress(t) case *extensions.DaemonSet: if t.Namespace == "" { t.Namespace = api.NamespaceDefault } - errors = expvalidation.ValidateDaemonSet(t) + errors = ext_validation.ValidateDaemonSet(t) case *extensions.PodSecurityPolicy: - errors = expvalidation.ValidatePodSecurityPolicy(t) + errors = ext_validation.ValidatePodSecurityPolicy(t) case *batch.CronJob: if t.Namespace == "" { t.Namespace = api.NamespaceDefault @@ -218,45 +230,76 @@ func walkConfigFiles(inDir string, fn func(name, path string, data [][]byte)) er } func TestExampleObjectSchemas(t *testing.T) { + // Please help maintain the alphabeta order in the map cases := map[string]map[string][]runtime.Object{ - "../docs/user-guide/walkthrough": { - "deployment": {&extensions.Deployment{}}, - "deployment-update": {&extensions.Deployment{}}, - "pod-nginx": {&api.Pod{}}, - "pod-nginx-with-label": {&api.Pod{}}, - "pod-redis": {&api.Pod{}}, - "pod-with-http-healthcheck": {&api.Pod{}}, - "pod-with-tcp-socket-healthcheck": {&api.Pod{}}, - "podtemplate": {&api.PodTemplate{}}, - "service": {&api.Service{}}, + "../docs/admin/high-availability": { + "etcd": {&api.Pod{}}, + "kube-apiserver": {&api.Pod{}}, + "kube-controller-manager": {&api.Pod{}}, + "kube-scheduler": {&api.Pod{}}, + "podmaster": {&api.Pod{}}, }, - "../docs/user-guide/update-demo": { - "kitten-rc": {&api.ReplicationController{}}, - "nautilus-rc": {&api.ReplicationController{}}, + "../docs/admin/limitrange": { + "invalid-pod": {&api.Pod{}}, + "limits": {&api.LimitRange{}}, + "namespace": {&api.Namespace{}}, + "valid-pod": {&api.Pod{}}, + }, + "../docs/admin/multiple-schedulers": { + "my-scheduler": {&extensions.Deployment{}}, + "pod1": {&api.Pod{}}, + "pod2": {&api.Pod{}}, + "pod3": {&api.Pod{}}, + }, + "../docs/admin/namespaces": { + "namespace-dev": {&api.Namespace{}}, + "namespace-prod": {&api.Namespace{}}, + }, + "../docs/admin/resourcequota": { + "best-effort": {&api.ResourceQuota{}}, + "compute-resources": {&api.ResourceQuota{}}, + "limits": {&api.LimitRange{}}, + "namespace": {&api.Namespace{}}, + "not-best-effort": {&api.ResourceQuota{}}, + "object-counts": {&api.ResourceQuota{}}, + }, + "../docs/concepts/cluster-administration": { + "counter-pod": {&api.Pod{}}, + "fluentd-sidecar-config": {&api.ConfigMap{}}, + "nginx-app": {&api.Service{}, &extensions.Deployment{}}, + "two-files-counter-pod": {&api.Pod{}}, + "two-files-counter-pod-agent-sidecar": {&api.Pod{}}, + "two-files-counter-pod-streaming-sidecar": {&api.Pod{}}, + }, + "../docs/concepts/configuration": { + "commands": {&api.Pod{}}, + "pod": {&api.Pod{}}, + "pod-with-node-affinity": {&api.Pod{}}, + "pod-with-pod-affinity": {&api.Pod{}}, + }, + "../docs/concepts/overview/working-with-objects": { + "nginx-deployment": {&extensions.Deployment{}}, }, "../docs/concepts/policy": { "psp": {&extensions.PodSecurityPolicy{}}, }, - "../docs/user-guide/persistent-volumes/volumes": { - "local-01": {&api.PersistentVolume{}}, - "local-02": {&api.PersistentVolume{}}, - "gce": {&api.PersistentVolume{}}, - "nfs": {&api.PersistentVolume{}}, + "../docs/concepts/services-networking": { + "curlpod": {&extensions.Deployment{}}, + "hostaliases-pod": {&api.Pod{}}, + "ingress": {&extensions.Ingress{}}, + "nginx-secure-app": {&api.Service{}, &extensions.Deployment{}}, + "nginx-svc": {&api.Service{}}, + "run-my-nginx": {&extensions.Deployment{}}, }, - "../docs/user-guide/persistent-volumes/claims": { - "claim-01": {&api.PersistentVolumeClaim{}}, - "claim-02": {&api.PersistentVolumeClaim{}}, - "claim-03": {&api.PersistentVolumeClaim{}}, - }, - "../docs/user-guide/persistent-volumes/simpletest": { - "namespace": {&api.Namespace{}}, - "pod": {&api.Pod{}}, - "service": {&api.Service{}}, - }, - "../docs/user-guide/liveness": { - "exec-liveness": {&api.Pod{}}, - "http-liveness": {&api.Pod{}}, - "http-liveness-named-port": {&api.Pod{}}, + "../docs/concepts/workloads/controllers": { + "cronjob": {&batch.CronJob{}}, + "daemonset": {&extensions.DaemonSet{}}, + "frontend": {&extensions.ReplicaSet{}}, + "hpa-rs": {&autoscaling.HorizontalPodAutoscaler{}}, + "job": {&batch.Job{}}, + "my-repset": {&extensions.ReplicaSet{}}, + "nginx-deployment": {&extensions.Deployment{}}, + "replication": {&api.ReplicationController{}}, }, "../docs/tasks/job/coarse-parallel-processing-work-queue": { "job": {&batch.Job{}}, @@ -266,6 +309,18 @@ func TestExampleObjectSchemas(t *testing.T) { "redis-pod": {&api.Pod{}}, "redis-service": {&api.Service{}}, }, + "../docs/tutorials/stateful-application": { + "gce-volume": {&api.PersistentVolume{}}, + "mysql-deployment": {&api.Service{}, &api.PersistentVolumeClaim{}, &extensions.Deployment{}}, + "mysql-services": {&api.Service{}, &api.Service{}}, + "mysql-configmap": {&api.ConfigMap{}}, + "mysql-statefulset": {&apps.StatefulSet{}}, + "cassandra-service": {&api.Service{}}, + "cassandra-statefulset": {&apps.StatefulSet{}, &storage.StorageClass{}}, + "web": {&api.Service{}, &apps.StatefulSet{}}, + "webp": {&api.Service{}, &apps.StatefulSet{}}, + "zookeeper": {&api.Service{}, &api.Service{}, &policy.PodDisruptionBudget{}, &apps.StatefulSet{}}, + }, "../docs/user-guide": { "bad-nginx-deployment": {&extensions.Deployment{}}, "counter-pod": {&api.Pod{}}, @@ -290,9 +345,6 @@ func TestExampleObjectSchemas(t *testing.T) { "run-my-nginx": {&extensions.Deployment{}}, "cronjob": {&batch.CronJob{}}, }, - "../docs/admin": { - "daemon": {&extensions.DaemonSet{}}, - }, "../docs/user-guide/downward-api": { "dapi-pod": {&api.Pod{}}, "dapi-container-resources": {&api.Pod{}}, @@ -301,45 +353,51 @@ func TestExampleObjectSchemas(t *testing.T) { "dapi-volume": {&api.Pod{}}, "dapi-volume-resources": {&api.Pod{}}, }, - "../docs/admin/namespaces": { - "namespace-dev": {&api.Namespace{}}, - "namespace-prod": {&api.Namespace{}}, - }, - "../docs/admin/limitrange": { - "invalid-pod": {&api.Pod{}}, - "limits": {&api.LimitRange{}}, - "namespace": {&api.Namespace{}}, - "valid-pod": {&api.Pod{}}, + "../docs/user-guide/liveness": { + "exec-liveness": {&api.Pod{}}, + "http-liveness": {&api.Pod{}}, + "http-liveness-named-port": {&api.Pod{}}, }, "../docs/user-guide/node-selection": { "pod": {&api.Pod{}}, "pod-with-node-affinity": {&api.Pod{}}, "pod-with-pod-affinity": {&api.Pod{}}, }, - "../docs/admin/resourcequota": { - "best-effort": {&api.ResourceQuota{}}, - "compute-resources": {&api.ResourceQuota{}}, - "limits": {&api.LimitRange{}}, - "namespace": {&api.Namespace{}}, - "not-best-effort": {&api.ResourceQuota{}}, - "object-counts": {&api.ResourceQuota{}}, + "../docs/user-guide/persistent-volumes/volumes": { + "local-01": {&api.PersistentVolume{}}, + "local-02": {&api.PersistentVolume{}}, + "gce": {&api.PersistentVolume{}}, + "nfs": {&api.PersistentVolume{}}, + }, + "../docs/user-guide/persistent-volumes/claims": { + "claim-01": {&api.PersistentVolumeClaim{}}, + "claim-02": {&api.PersistentVolumeClaim{}}, + "claim-03": {&api.PersistentVolumeClaim{}}, + }, + "../docs/user-guide/persistent-volumes/simpletest": { + "namespace": {&api.Namespace{}}, + "pod": {&api.Pod{}}, + "service": {&api.Service{}}, }, "../docs/user-guide/secrets": { "secret-pod": {&api.Pod{}}, "secret": {&api.Secret{}}, "secret-env-pod": {&api.Pod{}}, }, - "../docs/tutorials/stateful-application": { - "gce-volume": {&api.PersistentVolume{}}, - "mysql-deployment": {&api.Service{}, &api.PersistentVolumeClaim{}, &extensions.Deployment{}}, - "mysql-services": {&api.Service{}, &api.Service{}}, - "mysql-configmap": {&api.ConfigMap{}}, - "mysql-statefulset": {&apps.StatefulSet{}}, - "cassandra-service": {&api.Service{}}, - "cassandra-statefulset": {&apps.StatefulSet{}, &storage.StorageClass{}}, - "web": {&api.Service{}, &apps.StatefulSet{}}, - "webp": {&api.Service{}, &apps.StatefulSet{}}, - "zookeeper": {&api.Service{}, &api.Service{}, &policy.PodDisruptionBudget{}, &apps.StatefulSet{}}, + "../docs/user-guide/update-demo": { + "kitten-rc": {&api.ReplicationController{}}, + "nautilus-rc": {&api.ReplicationController{}}, + }, + "../docs/user-guide/walkthrough": { + "deployment": {&extensions.Deployment{}}, + "deployment-update": {&extensions.Deployment{}}, + "pod-nginx": {&api.Pod{}}, + "pod-nginx-with-label": {&api.Pod{}}, + "pod-redis": {&api.Pod{}}, + "pod-with-http-healthcheck": {&api.Pod{}}, + "pod-with-tcp-socket-healthcheck": {&api.Pod{}}, + "podtemplate": {&api.PodTemplate{}}, + "service": {&api.Service{}}, }, }