diff --git a/Makefile b/Makefile index 79e5cb46..6b57bb8c 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ $(GENERATED): go.mod $(CRD_TYPE_SOURCE) ./hack/update-codegen.sh $(GENERATED_CRDS): $(GENERATED) $(CRD_SOURCES) - go tool controller-gen crd:crdVersions=v1,allowDangerousTypes=true paths=./pkg/apis/... output:crd:dir=docs + go tool controller-gen crd:crdVersions=v1,allowDangerousTypes=true,generateEmbeddedObjectMeta=true paths=./pkg/apis/... output:crd:dir=docs go run hack/crd/trim.go < docs/zalando.org_stacksets.yaml > docs/stackset_crd.yaml go run hack/crd/trim.go < docs/zalando.org_stacks.yaml > docs/stack_crd.yaml rm docs/zalando.org_stacksets.yaml docs/zalando.org_stacks.yaml diff --git a/cmd/e2e/basic_test.go b/cmd/e2e/basic_test.go index cd4255a8..659a24b7 100644 --- a/cmd/e2e/basic_test.go +++ b/cmd/e2e/basic_test.go @@ -14,13 +14,13 @@ import ( apps "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/networking/v1" + networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" ) var ( - pathType = v1.PathTypeImplementationSpecific + pathType = networkingv1.PathTypeImplementationSpecific testAnnotationsCreate = map[string]string{ "user-test-annotation": "create", } @@ -179,7 +179,7 @@ func (f *TestStacksetSpecFactory) Create(t *testing.T, stackVersion string) zv1. Spec: zv1.StackSpecTemplate{ StackSpec: zv1.StackSpec{ Replicas: pint32(f.replicas), - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: corev1.PodTemplateSpec{ Spec: skipperPod, }, Service: &zv1.StackServiceSpec{ @@ -506,19 +506,19 @@ func verifyStackIngressSources( require.Contains(t, stackIngress.Annotations, k) require.Equal(t, v, stackIngress.Annotations[k]) } - stackIngressRules := make([]v1.IngressRule, 0, len(clusterDomains)) + stackIngressRules := make([]networkingv1.IngressRule, 0, len(clusterDomains)) for _, domain := range domains { - stackIngressRules = append(stackIngressRules, v1.IngressRule{ + stackIngressRules = append(stackIngressRules, networkingv1.IngressRule{ Host: domain, - IngressRuleValue: v1.IngressRuleValue{ - HTTP: &v1.HTTPIngressRuleValue{ - Paths: []v1.HTTPIngressPath{ + IngressRuleValue: networkingv1.IngressRuleValue{ + HTTP: &networkingv1.HTTPIngressRuleValue{ + Paths: []networkingv1.HTTPIngressPath{ { PathType: &pathType, - Backend: v1.IngressBackend{ - Service: &v1.IngressServiceBackend{ + Backend: networkingv1.IngressBackend{ + Service: &networkingv1.IngressServiceBackend{ Name: stack.Name, - Port: v1.ServiceBackendPort{ + Port: networkingv1.ServiceBackendPort{ Number: 80, }, }, diff --git a/controller/stackset_test.go b/controller/stackset_test.go index 026cdccf..8f2d656a 100644 --- a/controller/stackset_test.go +++ b/controller/stackset_test.go @@ -336,7 +336,7 @@ func TestCreateCurrentStack(t *testing.T) { Version: "v1", StackSpec: zv1.StackSpec{ Replicas: &replicas, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { diff --git a/docs/stack_crd.yaml b/docs/stack_crd.yaml index 3b1f68b7..a3b2b6ae 100644 --- a/docs/stack_crd.yaml +++ b/docs/stack_crd.yaml @@ -526,26 +526,26 @@ spec: description: PodTemplate describes the pods that will be created. properties: metadata: - description: Object's metadata. + description: |- + Standard object's metadata. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata properties: annotations: additionalProperties: type: string - description: |- - Annotations is an unstructured key value map stored with a resource that may be - set by external tools to store and retrieve arbitrary metadata. They are not - queryable and should be preserved when modifying objects. - More info: http://kubernetes.io/docs/user-guide/annotations type: object + finalizers: + items: + type: string + type: array labels: additionalProperties: type: string - description: |- - Map of string keys and values that can be used to organize and categorize - (scope and select) objects. May match selectors of replication controllers - and services. - More info: http://kubernetes.io/docs/user-guide/labels type: object + name: + type: string + namespace: + type: string type: object spec: description: |- @@ -1101,6 +1101,11 @@ spec: type: object x-kubernetes-map-type: atomic namespaces: + description: |- + namespaces specifies a static list of namespace names that the term applies to. + The term is applied to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + null or empty namespaces list and null namespaceSelector means "this pod's namespace". items: type: string type: array @@ -6287,6 +6292,12 @@ spec: properties: name: default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names type: string type: object x-kubernetes-map-type: atomic @@ -6448,6 +6459,23 @@ spec: May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation. + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: description: |- @@ -7231,12 +7259,6 @@ spec: properties: name: default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names type: string type: object x-kubernetes-map-type: atomic @@ -7390,12 +7412,6 @@ spec: properties: name: default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names type: string type: object x-kubernetes-map-type: atomic diff --git a/docs/stackset_crd.yaml b/docs/stackset_crd.yaml index add50f63..9c2129be 100644 --- a/docs/stackset_crd.yaml +++ b/docs/stackset_crd.yaml @@ -738,26 +738,26 @@ spec: description: PodTemplate describes the pods that will be created. properties: metadata: - description: Object's metadata. + description: |- + Standard object's metadata. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata properties: annotations: additionalProperties: type: string - description: |- - Annotations is an unstructured key value map stored with a resource that may be - set by external tools to store and retrieve arbitrary metadata. They are not - queryable and should be preserved when modifying objects. - More info: http://kubernetes.io/docs/user-guide/annotations type: object + finalizers: + items: + type: string + type: array labels: additionalProperties: type: string - description: |- - Map of string keys and values that can be used to organize and categorize - (scope and select) objects. May match selectors of replication controllers - and services. - More info: http://kubernetes.io/docs/user-guide/labels type: object + name: + type: string + namespace: + type: string type: object spec: description: |- @@ -6694,6 +6694,23 @@ spec: May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation. + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: description: |- diff --git a/pkg/apis/zalando.org/v1/types.go b/pkg/apis/zalando.org/v1/types.go index 74191701..e8862501 100644 --- a/pkg/apis/zalando.org/v1/types.go +++ b/pkg/apis/zalando.org/v1/types.go @@ -396,19 +396,6 @@ type Stack struct { Status StackStatus `json:"status"` } -// PodTemplateSpec describes the data a pod should have when created from a template -// +k8s:deepcopy-gen=true -type PodTemplateSpec struct { - // Object's metadata. - // +optional - EmbeddedObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - - // Specification of the desired behavior of the pod. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional - Spec v1.PodSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` -} - // StackSpec is the spec part of the Stack. // +k8s:deepcopy-gen=true type StackSpec struct { @@ -426,7 +413,7 @@ type StackSpec struct { // container port and ingress backendport. Service *StackServiceSpec `json:"service,omitempty"` // PodTemplate describes the pods that will be created. - PodTemplate PodTemplateSpec `json:"podTemplate"` + PodTemplate v1.PodTemplateSpec `json:"podTemplate"` Autoscaler *Autoscaler `json:"autoscaler,omitempty"` diff --git a/pkg/apis/zalando.org/v1/zz_generated.deepcopy.go b/pkg/apis/zalando.org/v1/zz_generated.deepcopy.go index 59e7d70d..33978777 100644 --- a/pkg/apis/zalando.org/v1/zz_generated.deepcopy.go +++ b/pkg/apis/zalando.org/v1/zz_generated.deepcopy.go @@ -529,24 +529,6 @@ func (in *PlatformCredentialsStatus) DeepCopy() *PlatformCredentialsStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodTemplateSpec) DeepCopyInto(out *PodTemplateSpec) { - *out = *in - in.EmbeddedObjectMeta.DeepCopyInto(&out.EmbeddedObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodTemplateSpec. -func (in *PodTemplateSpec) DeepCopy() *PodTemplateSpec { - if in == nil { - return nil - } - out := new(PodTemplateSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PrescalingStatus) DeepCopyInto(out *PrescalingStatus) { *out = *in diff --git a/pkg/core/stack_resources.go b/pkg/core/stack_resources.go index 1aabd88b..5c8550a0 100644 --- a/pkg/core/stack_resources.go +++ b/pkg/core/stack_resources.go @@ -231,7 +231,7 @@ func (sc *StackContainer) GenerateDeployment() *appsv1.Deployment { strategy = stack.Spec.StackSpec.Strategy.DeepCopy() } - embeddedCopy := stack.Spec.StackSpec.PodTemplate.EmbeddedObjectMeta.DeepCopy() + embeddedCopy := stack.Spec.StackSpec.PodTemplate.ObjectMeta.DeepCopy() templateObjectMeta := metav1.ObjectMeta{ Annotations: embeddedCopy.Annotations, diff --git a/pkg/core/stack_resources_test.go b/pkg/core/stack_resources_test.go index 1ecc28d6..2ebee43e 100644 --- a/pkg/core/stack_resources_test.go +++ b/pkg/core/stack_resources_test.go @@ -72,7 +72,7 @@ func TestGetServicePorts(tt *testing.T) { stackSpec: zv1.StackSpecInternal{ StackSpec: zv1.StackSpec{ Service: nil, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { @@ -115,7 +115,7 @@ func TestGetServicePorts(tt *testing.T) { stackSpec: zv1.StackSpecInternal{ StackSpec: zv1.StackSpec{ Service: nil, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { @@ -145,7 +145,7 @@ func TestGetServicePorts(tt *testing.T) { stackSpec: zv1.StackSpecInternal{ StackSpec: zv1.StackSpec{ Service: nil, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { @@ -176,7 +176,7 @@ func TestGetServicePorts(tt *testing.T) { stackSpec: zv1.StackSpecInternal{ StackSpec: zv1.StackSpec{ Service: nil, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { @@ -217,7 +217,7 @@ func TestGetServicePorts(tt *testing.T) { }, }, }, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { @@ -1166,7 +1166,7 @@ func TestStackGenerateService(t *testing.T) { Spec: zv1.StackSpecInternal{ StackSpec: zv1.StackSpec{ Service: nil, - PodTemplate: zv1.PodTemplateSpec{ + PodTemplate: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { @@ -1415,8 +1415,8 @@ func TestStackGenerateDeployment(t *testing.T) { StackSpec: zv1.StackSpec{ MinReadySeconds: tc.minReadySeconds, Strategy: strategy, - PodTemplate: zv1.PodTemplateSpec{ - EmbeddedObjectMeta: zv1.EmbeddedObjectMeta{ + PodTemplate: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "pod-label": "pod-foo", }, @@ -1603,8 +1603,8 @@ func TestGenerateHPA(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - podTemplate := zv1.PodTemplateSpec{ - EmbeddedObjectMeta: zv1.EmbeddedObjectMeta{ + podTemplate := v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "pod-label": "pod-foo", }, @@ -1679,8 +1679,8 @@ func TestGenerateHPAToSegment(t *testing.T) { ObjectMeta: testStackMeta, Spec: zv1.StackSpecInternal{ StackSpec: zv1.StackSpec{ - PodTemplate: zv1.PodTemplateSpec{ - EmbeddedObjectMeta: zv1.EmbeddedObjectMeta{ + PodTemplate: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "pod-label": "pod-foo", },