diff --git a/Makefile b/Makefile index 1034a28a65..d7fbc92a17 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ else CONTROLLER_GEN=$(shell which controller-gen) endif +# Produce CRDs that work back to Kubernetes <1.13 (no version conversion) +CRD_OPTIONS ?= "crd:trivialVersions=true" + ## -- Docker image # on GKE, use GCR and GCLOUD_PROJECT @@ -98,6 +101,9 @@ generate: controller-gen # we use this in pkg/controller/common/license go generate -tags='$(GO_TAGS)' ./pkg/... ./cmd/... $(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/... + # Generate manifests e.g. CRD, RBAC etc. + $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/..." output:crd:artifacts:config=config/crds + cd hack/patch-crd && go run main.go $(MAKE) --no-print-directory generate-all-in-one # TODO (sabo): reenable when new tag is cut and can work with the new repo path # $(MAKE) --no-print-directory generate-api-docs diff --git a/config/crds/apm.k8s.elastic.co_apmservers.yaml b/config/crds/apm.k8s.elastic.co_apmservers.yaml new file mode 100644 index 0000000000..7a78e85cf1 --- /dev/null +++ b/config/crds/apm.k8s.elastic.co_apmservers.yaml @@ -0,0 +1,386 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: apmservers.apm.k8s.elastic.co +spec: + additionalPrinterColumns: + - JSONPath: .status.health + name: health + type: string + - JSONPath: .status.availableNodes + description: Available nodes + name: nodes + type: integer + - JSONPath: .spec.version + description: APM version + name: version + type: string + - JSONPath: .metadata.creationTimestamp + name: age + type: date + group: apm.k8s.elastic.co + names: + categories: + - elastic + kind: ApmServer + listKind: ApmServerList + plural: apmservers + shortNames: + - apm + singular: apmserver + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: ApmServer is the Schema for the apmservers API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ApmServerSpec defines the desired state of ApmServer + properties: + config: + description: Config represents the APM configuration. + type: object + elasticsearchRef: + description: ElasticsearchRef references an Elasticsearch resource in + the Kubernetes cluster. If the namespace is not specified, the current + resource namespace will be used. + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object + http: + description: HTTP contains settings for HTTP. + properties: + service: + description: Service is a template for the Kubernetes Service + properties: + metadata: + description: ObjectMeta is metadata for the service. The name + and namespace provided here is managed by ECK and will be + ignored. + type: object + spec: + description: Spec defines the behavior of the service. + properties: + clusterIP: + description: 'clusterIP is the IP address of the service + and is usually assigned randomly by the master. If an + address is specified manually and is not in use by others, + it will be allocated to the service; otherwise, creation + of the service will fail. This field can not be changed + through updates. Valid values are "None", empty string + (""), or a valid IP address. "None" can be specified for + headless services when proxying is not required. Only + applies to types ClusterIP, NodePort, and LoadBalancer. + Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + type: string + externalIPs: + description: externalIPs is a list of IP addresses for which + nodes in the cluster will also accept traffic for this + service. These IPs are not managed by Kubernetes. The + user is responsible for ensuring that traffic arrives + at a node with this IP. A common example is external + load-balancers that are not part of the Kubernetes system. + items: + type: string + type: array + externalName: + description: externalName is the external reference that + kubedns or equivalent will return as a CNAME record for + this service. No proxying will be involved. Must be a + valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) + and requires Type to be ExternalName. + type: string + externalTrafficPolicy: + description: externalTrafficPolicy denotes if this Service + desires to route external traffic to node-local or cluster-wide + endpoints. "Local" preserves the client source IP and + avoids a second hop for LoadBalancer and Nodeport type + services, but risks potentially imbalanced traffic spreading. + "Cluster" obscures the client source IP and may cause + a second hop to another node, but should have good overall + load-spreading. + type: string + healthCheckNodePort: + description: healthCheckNodePort specifies the healthcheck + nodePort for the service. If not specified, HealthCheckNodePort + is created by the service api backend with the allocated + nodePort. Will use user-specified nodePort value if specified + by the client. Only effects when Type is set to LoadBalancer + and ExternalTrafficPolicy is set to Local. + format: int32 + type: integer + loadBalancerIP: + description: 'Only applies to Service Type: LoadBalancer + LoadBalancer will get created with the IP specified in + this field. This feature depends on whether the underlying + cloud-provider supports specifying the loadBalancerIP + when a load balancer is created. This field will be ignored + if the cloud-provider does not support the feature.' + type: string + loadBalancerSourceRanges: + description: 'If specified and supported by the platform, + this will restrict traffic through the cloud-provider + load-balancer will be restricted to the specified client + IPs. This field will be ignored if the cloud-provider + does not support the feature." More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' + items: + type: string + type: array + ports: + description: 'The list of ports that are exposed by this + service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + items: + description: ServicePort contains information on service's + port. + properties: + name: + description: The name of this port within the service. + This must be a DNS_LABEL. All ports within a ServiceSpec + must have unique names. This maps to the 'Name' + field in EndpointPort objects. Optional if only + one ServicePort is defined on this service. + type: string + nodePort: + description: 'The port on each node on which this + service is exposed when type=NodePort or LoadBalancer. + Usually assigned by the system. If specified, it + will be allocated to the service if unused or else + creation of the service will fail. Default is to + auto-allocate a port if the ServiceType of this + Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport' + format: int32 + type: integer + port: + description: The port that will be exposed by this + service. + format: int32 + type: integer + protocol: + description: The IP protocol for this port. Supports + "TCP", "UDP", and "SCTP". Default is TCP. + type: string + targetPort: + anyOf: + - type: string + - type: integer + description: 'Number or name of the port to access + on the pods targeted by the service. Number must + be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + 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 value of the ''port'' field + is used (an identity map). This field is ignored + for services with clusterIP=None, and should be + omitted or set equal to the ''port'' field. More + info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service' + required: + - port + type: object + type: array + publishNotReadyAddresses: + description: publishNotReadyAddresses, when set to true, + indicates that DNS implementations must publish the notReadyAddresses + of subsets for the Endpoints associated with the Service. + The default value is false. The primary use case for setting + this field is to use a StatefulSet's Headless Service + to propagate SRV records for its Pods without respect + to their readiness for purpose of peer discovery. + type: boolean + selector: + additionalProperties: + type: string + description: 'Route service traffic to pods with label keys + and values matching this selector. If empty or not present, + the service is assumed to have an external process managing + its endpoints, which Kubernetes will not modify. Only + applies to types ClusterIP, NodePort, and LoadBalancer. + Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/' + type: object + sessionAffinity: + description: 'Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None. More info: + https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of + Client IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object + type: + description: 'type determines how the Service is exposed. + Defaults to ClusterIP. Valid options are ExternalName, + ClusterIP, NodePort, and LoadBalancer. "ExternalName" + maps to the specified externalName. "ClusterIP" allocates + a cluster-internal IP address for load-balancing to endpoints. + Endpoints are determined by the selector or if that is + not specified, by manual construction of an Endpoints + object. If clusterIP is "None", no virtual IP is allocated + and the endpoints are published as a set of endpoints + rather than a stable IP. "NodePort" builds on ClusterIP + and allocates a port on every node which routes to the + clusterIP. "LoadBalancer" builds on NodePort and creates + an external load-balancer (if supported in the current + cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types' + type: string + type: object + type: object + tls: + description: TLS describe additional options to consider when generating + HTTP TLS certificates. + properties: + certificate: + description: "Certificate is a reference to a secret that contains + the certificate and private key to be used. \n The secret + should have the following content: \n - `ca.crt`: The certificate + authority (optional) - `tls.crt`: The certificate (or a chain). + - `tls.key`: The private key to the first certificate in the + certificate chain." + properties: + secretName: + type: string + type: object + selfSignedCertificate: + description: SelfSignedCertificate define options to apply to + self-signed certificate managed by the operator. + properties: + disabled: + description: Disabled turns off the provisioning of self-signed + HTTP TLS certificates. + type: boolean + subjectAltNames: + description: 'SubjectAlternativeNames is a list of SANs + to include in the HTTP TLS certificates. For example: + a wildcard DNS to expose the cluster.' + items: + properties: + dns: + type: string + ip: + type: string + type: object + type: array + type: object + type: object + type: object + image: + description: Image represents the docker image that will be used. + type: string + nodeCount: + description: NodeCount defines how many nodes the Apm Server deployment + must have. + format: int32 + type: integer + secureSettings: + description: SecureSettings references secrets containing secure settings, + to be injected into the APM keystore on each node. Each individual + key/value entry in the referenced secrets is considered as an individual + secure setting to be injected. You can use the `entries` and `key` + fields to consider only a subset of the secret entries and the `path` + field to change the target path of a secret entry key. The secret + must exist in the same namespace as the APM resource. + items: + properties: + entries: + description: If unspecified, each key-value pair in the Data field + of the referenced Secret will be projected into the volume as + a file whose name is the key and content is the value. If specified, + the listed keys will be projected into the specified paths, + and unlisted keys will not be present. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: The key to project. + type: string + path: + description: The relative path of the file to map the key + to. May not be an absolute path. May not contain the path + element '..'. May not start with the string '..'. + type: string + required: + - key + type: object + type: array + secretName: + description: 'Name of the secret in the pod''s namespace to use. + More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' + type: string + required: + - secretName + type: object + type: array + version: + description: Version represents the version of the APM Server + type: string + type: object + status: + description: ApmServerStatus defines the observed state of ApmServer + properties: + associationStatus: + description: Association is the status of any auto-linking to Elasticsearch + clusters. + type: string + availableNodes: + type: integer + health: + description: ApmServerHealth expresses the status of the Apm Server + instances. + type: string + secretTokenSecret: + description: SecretTokenSecretName is the name of the Secret that contains + the secret token + type: string + service: + description: ExternalService is the name of the service the agents should + connect to. + type: string + type: object + type: object + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: false + - name: v1beta1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crds/apm_v1alpha1_apmserver.yaml b/config/crds/apm_v1alpha1_apmserver.yaml deleted file mode 100644 index 7f71fd1616..0000000000 --- a/config/crds/apm_v1alpha1_apmserver.yaml +++ /dev/null @@ -1,193 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - creationTimestamp: null - labels: - controller-tools.k8s.io: "1.0" - name: apmservers.apm.k8s.elastic.co -spec: - additionalPrinterColumns: - - JSONPath: .status.health - name: health - type: string - - JSONPath: .status.availableNodes - description: Available nodes - name: nodes - type: integer - - JSONPath: .spec.version - description: APM version - name: version - type: string - - JSONPath: .metadata.creationTimestamp - name: age - type: date - group: apm.k8s.elastic.co - names: - categories: - - elastic - kind: ApmServer - plural: apmservers - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - properties: - config: - description: Config represents the APM configuration. - type: object - elasticsearchRef: - description: ElasticsearchRef references an Elasticsearch resource in - the Kubernetes cluster. If the namespace is not specified, the current - resource namespace will be used. - properties: - name: - type: string - namespace: - type: string - required: - - name - type: object - http: - description: HTTP contains settings for HTTP. - properties: - service: - description: Service is a template for the Kubernetes Service - properties: - metadata: - description: ObjectMeta is metadata for the service. The name - and namespace provided here is managed by ECK and will be - ignored. - type: object - spec: - description: Spec defines the behavior of the service. - type: object - type: object - tls: - description: TLS describe additional options to consider when generating - HTTP TLS certificates. - properties: - certificate: - description: 'Certificate is a reference to a secret that contains - the certificate and private key to be used. The secret should - have the following content: - `ca.crt`: The certificate authority - (optional) - `tls.crt`: The certificate (or a chain). - `tls.key`: - The private key to the first certificate in the certificate - chain.' - properties: - secretName: - type: string - type: object - selfSignedCertificate: - description: SelfSignedCertificate define options to apply to - self-signed certificate managed by the operator. - properties: - disabled: - description: Disabled turns off the provisioning of self-signed - HTTP TLS certificates. - type: boolean - subjectAltNames: - description: 'SubjectAlternativeNames is a list of SANs - to include in the HTTP TLS certificates. For example: - a wildcard DNS to expose the cluster.' - items: - properties: - dns: - type: string - ip: - type: string - type: object - type: array - type: object - type: object - type: object - image: - description: Image represents the docker image that will be used. - type: string - nodeCount: - description: NodeCount defines how many nodes the Apm Server deployment - must have. - format: int32 - type: integer - podTemplate: - description: PodTemplate can be used to propagate configuration to APM - Server pods. This allows specifying custom annotations, labels, environment - variables, affinity, resources, etc. for the pods created from this - NodeSpec. - type: object - secureSettings: - description: SecureSettings references secrets containing secure settings, - to be injected into the APM keystore on each node. Each individual - key/value entry in the referenced secrets is considered as an individual - secure setting to be injected. You can use the `entries` and `key` - fields to consider only a subset of the secret entries and the `path` - field to change the target path of a secret entry key. The secret - must exist in the same namespace as the APM resource. - items: - properties: - entries: - description: If unspecified, each key-value pair in the Data field - of the referenced Secret will be projected into the volume as - a file whose name is the key and content is the value. If specified, - the listed keys will be projected into the specified paths, - and unlisted keys will not be present. - items: - properties: - key: - description: The key to project. - type: string - path: - description: The relative path of the file to map the key - to. May not be an absolute path. May not contain the path - element '..'. May not start with the string '..'. - type: string - required: - - key - type: object - type: array - secretName: - description: 'Name of the secret in the pod''s namespace to use. - More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' - type: string - required: - - secretName - type: object - type: array - version: - description: Version represents the version of the APM Server - type: string - type: object - status: - properties: - health: - type: string - secretTokenSecret: - description: SecretTokenSecretName is the name of the Secret that contains - the secret token - type: string - service: - description: ExternalService is the name of the service the agents should - connect to. - type: string - type: object - version: v1alpha1 -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crds/elasticsearch.k8s.elastic.co_elasticsearches.yaml b/config/crds/elasticsearch.k8s.elastic.co_elasticsearches.yaml new file mode 100644 index 0000000000..2510241ee4 --- /dev/null +++ b/config/crds/elasticsearch.k8s.elastic.co_elasticsearches.yaml @@ -0,0 +1,53 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: elasticsearches.elasticsearch.k8s.elastic.co +spec: + additionalPrinterColumns: + - JSONPath: .status.health + name: health + type: string + - JSONPath: .status.availableNodes + description: Available nodes + name: nodes + type: integer + - JSONPath: .spec.version + description: Elasticsearch version + name: version + type: string + - JSONPath: .status.phase + name: phase + type: string + - JSONPath: .metadata.creationTimestamp + name: age + type: date + group: elasticsearch.k8s.elastic.co + names: + categories: + - elastic + kind: Elasticsearch + listKind: ElasticsearchList + plural: elasticsearches + shortNames: + - es + singular: elasticsearch + scope: Namespaced + subresources: + status: {} + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: false + - name: v1beta1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crds/elasticsearch_v1alpha1_elasticsearch.yaml b/config/crds/elasticsearch_v1alpha1_elasticsearch.yaml deleted file mode 100644 index 479badd3dd..0000000000 --- a/config/crds/elasticsearch_v1alpha1_elasticsearch.yaml +++ /dev/null @@ -1,283 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - creationTimestamp: null - labels: - controller-tools.k8s.io: "1.0" - name: elasticsearches.elasticsearch.k8s.elastic.co -spec: - additionalPrinterColumns: - - JSONPath: .status.health - name: health - type: string - - JSONPath: .status.availableNodes - description: Available nodes - name: nodes - type: integer - - JSONPath: .spec.version - description: Elasticsearch version - name: version - type: string - - JSONPath: .status.phase - name: phase - type: string - - JSONPath: .metadata.creationTimestamp - name: age - type: date - group: elasticsearch.k8s.elastic.co - names: - categories: - - elastic - kind: Elasticsearch - plural: elasticsearches - shortNames: - - es - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - properties: - http: - description: HTTP contains settings for HTTP. - properties: - service: - description: Service is a template for the Kubernetes Service - properties: - metadata: - description: ObjectMeta is metadata for the service. The name - and namespace provided here is managed by ECK and will be - ignored. - type: object - spec: - description: Spec defines the behavior of the service. - type: object - type: object - tls: - description: TLS describe additional options to consider when generating - HTTP TLS certificates. - properties: - certificate: - description: 'Certificate is a reference to a secret that contains - the certificate and private key to be used. The secret should - have the following content: - `ca.crt`: The certificate authority - (optional) - `tls.crt`: The certificate (or a chain). - `tls.key`: - The private key to the first certificate in the certificate - chain.' - properties: - secretName: - type: string - type: object - selfSignedCertificate: - description: SelfSignedCertificate define options to apply to - self-signed certificate managed by the operator. - properties: - disabled: - description: Disabled turns off the provisioning of self-signed - HTTP TLS certificates. - type: boolean - subjectAltNames: - description: 'SubjectAlternativeNames is a list of SANs - to include in the HTTP TLS certificates. For example: - a wildcard DNS to expose the cluster.' - items: - properties: - dns: - type: string - ip: - type: string - type: object - type: array - type: object - type: object - type: object - image: - description: Image represents the docker image that will be used. - type: string - nodes: - description: Nodes represents a list of groups of nodes with the same - configuration to be part of the cluster - items: - properties: - config: - description: Config represents Elasticsearch configuration. - type: object - name: - description: Name is a logical name for this set of nodes. Used - as a part of the managed Elasticsearch node.name setting. - maxLength: 23 - pattern: '[a-zA-Z0-9-]+' - type: string - nodeCount: - description: NodeCount defines how many nodes have this topology - format: int32 - type: integer - podTemplate: - description: PodTemplate can be used to propagate configuration - to Elasticsearch pods. This allows specifying custom annotations, - labels, environment variables, volumes, affinity, resources, - etc. for the pods created from this NodeSpec. - type: object - volumeClaimTemplates: - description: 'VolumeClaimTemplates is a list of claims that pods - are allowed to reference. Every claim in this list must have - at least one matching (by name) volumeMount in one container - in the template. A claim in this list takes precedence over - any volumes in the template, with the same name. TODO: Define - the behavior if a claim already exists with the same name. TODO: - define special behavior based on claim metadata.name. (e.g data - / logs volumes)' - items: - type: object - type: array - required: - - name - type: object - type: array - podDisruptionBudget: - description: PodDisruptionBudget allows full control of the default - pod disruption budget. The default budget selects all cluster pods - and sets maxUnavailable to 1. To disable it entirely, set to the empty - value (`{}` in YAML). - properties: - metadata: - description: ObjectMeta is metadata for the service. The name and - namespace provided here is managed by ECK and will be ignored. - type: object - spec: - description: Spec of the desired behavior of the PodDisruptionBudget - type: object - type: object - secureSettings: - description: SecureSettings references secrets containing secure settings, - to be injected into Elasticsearch keystore on each node. Each individual - key/value entry in the referenced secrets is considered as an individual - secure setting to be injected. You can use the `entries` and `key` - fields to consider only a subset of the secret entries and the `path` - field to change the target path of a secret entry key. The secret - must exist in the same namespace as the Elasticsearch resource. - items: - properties: - entries: - description: If unspecified, each key-value pair in the Data field - of the referenced Secret will be projected into the volume as - a file whose name is the key and content is the value. If specified, - the listed keys will be projected into the specified paths, - and unlisted keys will not be present. - items: - properties: - key: - description: The key to project. - type: string - path: - description: The relative path of the file to map the key - to. May not be an absolute path. May not contain the path - element '..'. May not start with the string '..'. - type: string - required: - - key - type: object - type: array - secretName: - description: 'Name of the secret in the pod''s namespace to use. - More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' - type: string - required: - - secretName - type: object - type: array - setVmMaxMapCount: - description: SetVMMaxMapCount indicates whether an init container should - be used to ensure that the `vm.max_map_count` is set according to - https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html. - Setting this to true requires the kubelet to allow running privileged - containers. Defaults to true if not specified. To be disabled, it - must be explicitly set to false. - type: boolean - updateStrategy: - description: UpdateStrategy specifies how updates to the cluster should - be performed. - properties: - changeBudget: - description: ChangeBudget is the change budget that should be used - when performing mutations to the cluster. - properties: - maxSurge: - description: 'MaxSurge is the maximum number of pods that can - be scheduled above the original number of pods. By default, - a fixed value of 1 is used. Value can be an absolute number - (ex: 5) or a percentage of total pods at the start of the - update (ex: 10%). This can not be 0 if MaxUnavailable is 0 - if you want automatic rolling updates to be applied. Absolute - number is calculated from percentage by rounding up. Example: - when this is set to 30%, the new group can be scaled up by - 30% immediately when the rolling update starts. Once old pods - have been killed, new group can be scaled up further, ensuring - that total number of pods running at any time during the update - is at most 130% of the target number of pods.' - format: int64 - type: integer - maxUnavailable: - description: 'MaxUnavailable is the maximum number of pods that - can be unavailable during the update. Value can be an absolute - number (ex: 5) or a percentage of total pods at the start - of update (ex: 10%). Absolute number is calculated from percentage - by rounding down. This can not be 0 if MaxSurge is 0 if you - want automatic rolling changes to be applied. By default, - a fixed value of 0 is used. Example: when this is set to 30%, - the group can be scaled down by 30% immediately when the rolling - update starts. Once new pods are ready, the group can be scaled - down further, followed by scaling up the group, ensuring that - at least 70% of the target number of pods are available at - all times during the update.' - format: int64 - type: integer - required: - - maxUnavailable - - maxSurge - type: object - type: object - version: - description: Version represents the version of the stack - type: string - type: object - status: - properties: - clusterUUID: - type: string - health: - type: string - masterNode: - type: string - phase: - type: string - service: - type: string - zenDiscovery: - properties: - minimumMasterNodes: - format: int64 - type: integer - type: object - type: object - version: v1alpha1 -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crds/kibana.k8s.elastic.co_kibanas.yaml b/config/crds/kibana.k8s.elastic.co_kibanas.yaml new file mode 100644 index 0000000000..fe2e21bfcc --- /dev/null +++ b/config/crds/kibana.k8s.elastic.co_kibanas.yaml @@ -0,0 +1,376 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: kibanas.kibana.k8s.elastic.co +spec: + additionalPrinterColumns: + - JSONPath: .status.health + name: health + type: string + - JSONPath: .status.availableNodes + description: Available nodes + name: nodes + type: integer + - JSONPath: .spec.version + description: Kibana version + name: version + type: string + - JSONPath: .metadata.creationTimestamp + name: age + type: date + group: kibana.k8s.elastic.co + names: + categories: + - elastic + kind: Kibana + listKind: KibanaList + plural: kibanas + shortNames: + - kb + singular: kibana + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: Kibana is the Schema for the kibanas API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: KibanaSpec defines the desired state of Kibana + properties: + config: + description: Config represents Kibana configuration. + type: object + elasticsearchRef: + description: ElasticsearchRef references an Elasticsearch resource in + the Kubernetes cluster. If the namespace is not specified, the current + resource namespace will be used. + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object + http: + description: HTTP contains settings for HTTP. + properties: + service: + description: Service is a template for the Kubernetes Service + properties: + metadata: + description: ObjectMeta is metadata for the service. The name + and namespace provided here is managed by ECK and will be + ignored. + type: object + spec: + description: Spec defines the behavior of the service. + properties: + clusterIP: + description: 'clusterIP is the IP address of the service + and is usually assigned randomly by the master. If an + address is specified manually and is not in use by others, + it will be allocated to the service; otherwise, creation + of the service will fail. This field can not be changed + through updates. Valid values are "None", empty string + (""), or a valid IP address. "None" can be specified for + headless services when proxying is not required. Only + applies to types ClusterIP, NodePort, and LoadBalancer. + Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + type: string + externalIPs: + description: externalIPs is a list of IP addresses for which + nodes in the cluster will also accept traffic for this + service. These IPs are not managed by Kubernetes. The + user is responsible for ensuring that traffic arrives + at a node with this IP. A common example is external + load-balancers that are not part of the Kubernetes system. + items: + type: string + type: array + externalName: + description: externalName is the external reference that + kubedns or equivalent will return as a CNAME record for + this service. No proxying will be involved. Must be a + valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) + and requires Type to be ExternalName. + type: string + externalTrafficPolicy: + description: externalTrafficPolicy denotes if this Service + desires to route external traffic to node-local or cluster-wide + endpoints. "Local" preserves the client source IP and + avoids a second hop for LoadBalancer and Nodeport type + services, but risks potentially imbalanced traffic spreading. + "Cluster" obscures the client source IP and may cause + a second hop to another node, but should have good overall + load-spreading. + type: string + healthCheckNodePort: + description: healthCheckNodePort specifies the healthcheck + nodePort for the service. If not specified, HealthCheckNodePort + is created by the service api backend with the allocated + nodePort. Will use user-specified nodePort value if specified + by the client. Only effects when Type is set to LoadBalancer + and ExternalTrafficPolicy is set to Local. + format: int32 + type: integer + loadBalancerIP: + description: 'Only applies to Service Type: LoadBalancer + LoadBalancer will get created with the IP specified in + this field. This feature depends on whether the underlying + cloud-provider supports specifying the loadBalancerIP + when a load balancer is created. This field will be ignored + if the cloud-provider does not support the feature.' + type: string + loadBalancerSourceRanges: + description: 'If specified and supported by the platform, + this will restrict traffic through the cloud-provider + load-balancer will be restricted to the specified client + IPs. This field will be ignored if the cloud-provider + does not support the feature." More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' + items: + type: string + type: array + ports: + description: 'The list of ports that are exposed by this + service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + items: + description: ServicePort contains information on service's + port. + properties: + name: + description: The name of this port within the service. + This must be a DNS_LABEL. All ports within a ServiceSpec + must have unique names. This maps to the 'Name' + field in EndpointPort objects. Optional if only + one ServicePort is defined on this service. + type: string + nodePort: + description: 'The port on each node on which this + service is exposed when type=NodePort or LoadBalancer. + Usually assigned by the system. If specified, it + will be allocated to the service if unused or else + creation of the service will fail. Default is to + auto-allocate a port if the ServiceType of this + Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport' + format: int32 + type: integer + port: + description: The port that will be exposed by this + service. + format: int32 + type: integer + protocol: + description: The IP protocol for this port. Supports + "TCP", "UDP", and "SCTP". Default is TCP. + type: string + targetPort: + anyOf: + - type: string + - type: integer + description: 'Number or name of the port to access + on the pods targeted by the service. Number must + be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + 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 value of the ''port'' field + is used (an identity map). This field is ignored + for services with clusterIP=None, and should be + omitted or set equal to the ''port'' field. More + info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service' + required: + - port + type: object + type: array + publishNotReadyAddresses: + description: publishNotReadyAddresses, when set to true, + indicates that DNS implementations must publish the notReadyAddresses + of subsets for the Endpoints associated with the Service. + The default value is false. The primary use case for setting + this field is to use a StatefulSet's Headless Service + to propagate SRV records for its Pods without respect + to their readiness for purpose of peer discovery. + type: boolean + selector: + additionalProperties: + type: string + description: 'Route service traffic to pods with label keys + and values matching this selector. If empty or not present, + the service is assumed to have an external process managing + its endpoints, which Kubernetes will not modify. Only + applies to types ClusterIP, NodePort, and LoadBalancer. + Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/' + type: object + sessionAffinity: + description: 'Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None. More info: + https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of + Client IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object + type: + description: 'type determines how the Service is exposed. + Defaults to ClusterIP. Valid options are ExternalName, + ClusterIP, NodePort, and LoadBalancer. "ExternalName" + maps to the specified externalName. "ClusterIP" allocates + a cluster-internal IP address for load-balancing to endpoints. + Endpoints are determined by the selector or if that is + not specified, by manual construction of an Endpoints + object. If clusterIP is "None", no virtual IP is allocated + and the endpoints are published as a set of endpoints + rather than a stable IP. "NodePort" builds on ClusterIP + and allocates a port on every node which routes to the + clusterIP. "LoadBalancer" builds on NodePort and creates + an external load-balancer (if supported in the current + cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types' + type: string + type: object + type: object + tls: + description: TLS describe additional options to consider when generating + HTTP TLS certificates. + properties: + certificate: + description: "Certificate is a reference to a secret that contains + the certificate and private key to be used. \n The secret + should have the following content: \n - `ca.crt`: The certificate + authority (optional) - `tls.crt`: The certificate (or a chain). + - `tls.key`: The private key to the first certificate in the + certificate chain." + properties: + secretName: + type: string + type: object + selfSignedCertificate: + description: SelfSignedCertificate define options to apply to + self-signed certificate managed by the operator. + properties: + disabled: + description: Disabled turns off the provisioning of self-signed + HTTP TLS certificates. + type: boolean + subjectAltNames: + description: 'SubjectAlternativeNames is a list of SANs + to include in the HTTP TLS certificates. For example: + a wildcard DNS to expose the cluster.' + items: + properties: + dns: + type: string + ip: + type: string + type: object + type: array + type: object + type: object + type: object + image: + description: Image represents the docker image that will be used. + type: string + nodeCount: + description: NodeCount defines how many nodes the Kibana deployment + must have. + format: int32 + type: integer + secureSettings: + description: SecureSettings references secrets containing secure settings, + to be injected into Kibana keystore on each node. Each individual + key/value entry in the referenced secrets is considered as an individual + secure setting to be injected. You can use the `entries` and `key` + fields to consider only a subset of the secret entries and the `path` + field to change the target path of a secret entry key. The secret + must exist in the same namespace as the Kibana resource. + items: + properties: + entries: + description: If unspecified, each key-value pair in the Data field + of the referenced Secret will be projected into the volume as + a file whose name is the key and content is the value. If specified, + the listed keys will be projected into the specified paths, + and unlisted keys will not be present. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: The key to project. + type: string + path: + description: The relative path of the file to map the key + to. May not be an absolute path. May not contain the path + element '..'. May not start with the string '..'. + type: string + required: + - key + type: object + type: array + secretName: + description: 'Name of the secret in the pod''s namespace to use. + More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' + type: string + required: + - secretName + type: object + type: array + version: + description: Version represents the version of Kibana + type: string + type: object + status: + description: KibanaStatus defines the observed state of Kibana + properties: + associationStatus: + description: AssociationStatus is the status of an association resource. + type: string + availableNodes: + type: integer + health: + description: KibanaHealth expresses the status of the Kibana instances. + type: string + type: object + type: object + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: false + - name: v1beta1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crds/kibana_v1alpha1_kibana.yaml b/config/crds/kibana_v1alpha1_kibana.yaml deleted file mode 100644 index 8c56b61f53..0000000000 --- a/config/crds/kibana_v1alpha1_kibana.yaml +++ /dev/null @@ -1,189 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - creationTimestamp: null - labels: - controller-tools.k8s.io: "1.0" - name: kibanas.kibana.k8s.elastic.co -spec: - additionalPrinterColumns: - - JSONPath: .status.health - name: health - type: string - - JSONPath: .status.availableNodes - description: Available nodes - name: nodes - type: integer - - JSONPath: .spec.version - description: Kibana version - name: version - type: string - - JSONPath: .metadata.creationTimestamp - name: age - type: date - group: kibana.k8s.elastic.co - names: - categories: - - elastic - kind: Kibana - plural: kibanas - shortNames: - - kb - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - properties: - config: - description: Config represents Kibana configuration. - type: object - elasticsearchRef: - description: ElasticsearchRef references an Elasticsearch resource in - the Kubernetes cluster. If the namespace is not specified, the current - resource namespace will be used. - properties: - name: - type: string - namespace: - type: string - required: - - name - type: object - http: - description: HTTP contains settings for HTTP. - properties: - service: - description: Service is a template for the Kubernetes Service - properties: - metadata: - description: ObjectMeta is metadata for the service. The name - and namespace provided here is managed by ECK and will be - ignored. - type: object - spec: - description: Spec defines the behavior of the service. - type: object - type: object - tls: - description: TLS describe additional options to consider when generating - HTTP TLS certificates. - properties: - certificate: - description: 'Certificate is a reference to a secret that contains - the certificate and private key to be used. The secret should - have the following content: - `ca.crt`: The certificate authority - (optional) - `tls.crt`: The certificate (or a chain). - `tls.key`: - The private key to the first certificate in the certificate - chain.' - properties: - secretName: - type: string - type: object - selfSignedCertificate: - description: SelfSignedCertificate define options to apply to - self-signed certificate managed by the operator. - properties: - disabled: - description: Disabled turns off the provisioning of self-signed - HTTP TLS certificates. - type: boolean - subjectAltNames: - description: 'SubjectAlternativeNames is a list of SANs - to include in the HTTP TLS certificates. For example: - a wildcard DNS to expose the cluster.' - items: - properties: - dns: - type: string - ip: - type: string - type: object - type: array - type: object - type: object - type: object - image: - description: Image represents the docker image that will be used. - type: string - nodeCount: - description: NodeCount defines how many nodes the Kibana deployment - must have. - format: int32 - type: integer - podTemplate: - description: PodTemplate can be used to propagate configuration to Kibana - pods. This allows specifying custom annotations, labels, environment - variables, affinity, resources, etc. for the pods created from this - NodeSpec. - type: object - secureSettings: - description: SecureSettings references secrets containing secure settings, - to be injected into Kibana keystore on each node. Each individual - key/value entry in the referenced secrets is considered as an individual - secure setting to be injected. You can use the `entries` and `key` - fields to consider only a subset of the secret entries and the `path` - field to change the target path of a secret entry key. The secret - must exist in the same namespace as the Kibana resource. - items: - properties: - entries: - description: If unspecified, each key-value pair in the Data field - of the referenced Secret will be projected into the volume as - a file whose name is the key and content is the value. If specified, - the listed keys will be projected into the specified paths, - and unlisted keys will not be present. - items: - properties: - key: - description: The key to project. - type: string - path: - description: The relative path of the file to map the key - to. May not be an absolute path. May not contain the path - element '..'. May not start with the string '..'. - type: string - required: - - key - type: object - type: array - secretName: - description: 'Name of the secret in the pod''s namespace to use. - More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' - type: string - required: - - secretName - type: object - type: array - version: - description: Version represents the version of Kibana - type: string - type: object - status: - properties: - associationStatus: - type: string - health: - type: string - type: object - version: v1alpha1 -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/samples/apm/apm_es_kibana.yaml b/config/samples/apm/apm_es_kibana.yaml index cd635ea14f..1f5590d7f1 100644 --- a/config/samples/apm/apm_es_kibana.yaml +++ b/config/samples/apm/apm_es_kibana.yaml @@ -1,6 +1,6 @@ # This sample sets up a an Elasticsearch cluster along with a Kibana instance # and an APM server, configured to be able to communicate with each other -apiVersion: elasticsearch.k8s.elastic.co/v1alpha1 +apiVersion: elasticsearch.k8s.elastic.co/v1beta1 kind: Elasticsearch metadata: name: es-apm-sample @@ -10,7 +10,7 @@ spec: - name: default nodeCount: 3 --- -apiVersion: apm.k8s.elastic.co/v1alpha1 +apiVersion: apm.k8s.elastic.co/v1beta1 kind: ApmServer metadata: name: apm-apm-sample @@ -20,7 +20,7 @@ spec: elasticsearchRef: name: "es-apm-sample" --- -apiVersion: kibana.k8s.elastic.co/v1alpha1 +apiVersion: kibana.k8s.elastic.co/v1beta1 kind: Kibana metadata: name: kb-apm-sample diff --git a/config/samples/apm/apmserver.yaml b/config/samples/apm/apmserver.yaml index 67df553ee6..f561b37b46 100644 --- a/config/samples/apm/apmserver.yaml +++ b/config/samples/apm/apmserver.yaml @@ -1,4 +1,4 @@ -apiVersion: apm.k8s.elastic.co/v1alpha1 +apiVersion: apm.k8s.elastic.co/v1beta1 kind: ApmServer metadata: name: apmserver-sample diff --git a/config/samples/elasticsearch/elasticsearch.yaml b/config/samples/elasticsearch/elasticsearch.yaml index dbfd59e519..dd881d7ced 100644 --- a/config/samples/elasticsearch/elasticsearch.yaml +++ b/config/samples/elasticsearch/elasticsearch.yaml @@ -1,5 +1,5 @@ # This sample sets up an Elasticsearch cluster with 3 nodes. -apiVersion: elasticsearch.k8s.elastic.co/v1alpha1 +apiVersion: elasticsearch.k8s.elastic.co/v1beta1 kind: Elasticsearch metadata: name: elasticsearch-sample diff --git a/config/samples/kibana/kibana.yaml b/config/samples/kibana/kibana.yaml index 6020750bfc..7a48309135 100644 --- a/config/samples/kibana/kibana.yaml +++ b/config/samples/kibana/kibana.yaml @@ -1,5 +1,5 @@ # This sample sets up a single Kibana instance pointing to a remote Elasticsearch cluster -apiVersion: kibana.k8s.elastic.co/v1alpha1 +apiVersion: kibana.k8s.elastic.co/v1beta1 kind: Kibana metadata: name: kibana-sample diff --git a/config/samples/kibana/kibana_es.yaml b/config/samples/kibana/kibana_es.yaml index 0140a3c0f9..b86c83899b 100644 --- a/config/samples/kibana/kibana_es.yaml +++ b/config/samples/kibana/kibana_es.yaml @@ -1,5 +1,5 @@ # This sample sets up an Elasticsearch cluster and a Kibana instance preconfigured for that cluster -apiVersion: elasticsearch.k8s.elastic.co/v1alpha1 +apiVersion: elasticsearch.k8s.elastic.co/v1beta1 kind: Elasticsearch metadata: name: elasticsearch-sample @@ -9,7 +9,7 @@ spec: - name: default nodeCount: 1 --- -apiVersion: kibana.k8s.elastic.co/v1alpha1 +apiVersion: kibana.k8s.elastic.co/v1beta1 kind: Kibana metadata: name: kibana-sample diff --git a/docs/eck-attributes.asciidoc b/docs/eck-attributes.asciidoc index b46e92bcfa..171ca9124e 100644 --- a/docs/eck-attributes.asciidoc +++ b/docs/eck-attributes.asciidoc @@ -1,2 +1,2 @@ :eck_version: 1.0.0-beta1 -:eck_crd_version: v1alpha1 +:eck_crd_version: v1beta1 diff --git a/hack/patch-crd/go.mod b/hack/patch-crd/go.mod new file mode 100644 index 0000000000..ff029c4a0b --- /dev/null +++ b/hack/patch-crd/go.mod @@ -0,0 +1,9 @@ +module github.com/elastic/cloud-on-k8s/hack/patch-crd + +go 1.13 + +require ( + github.com/Jeffail/gabs v1.4.0 // indirect + gopkg.in/yaml.v2 v2.2.3 // indirect + sigs.k8s.io/yaml v1.1.0 // indirect +) diff --git a/hack/patch-crd/go.sum b/hack/patch-crd/go.sum new file mode 100644 index 0000000000..83dcf3f9ce --- /dev/null +++ b/hack/patch-crd/go.sum @@ -0,0 +1,7 @@ +github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= +github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/hack/patch-crd/main.go b/hack/patch-crd/main.go new file mode 100644 index 0000000000..b845ea2fb1 --- /dev/null +++ b/hack/patch-crd/main.go @@ -0,0 +1,83 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// This script patches the CRDs by removing the `podTemplate` schema which is present since the move to kubebuilder 2. +// To pass validation, `podTemplate.spec.containers` should always be set to an empty array if it's not used and another +// field is defined in `podTemplate.spec`. As it seems very compelling to always have to declare it, we remove it. +// More in the following issue: https://github.com/elastic/cloud-on-k8s/issues/1822. + +package main + +import ( + "io/ioutil" + "log" + "path/filepath" + + "github.com/Jeffail/gabs" + "sigs.k8s.io/yaml" +) + +const ( + crdsDirectory = "../../config/crds" + pathToRemove = "spec.validation.openAPIV3Schema.properties.spec.properties.podTemplate" +) + +func main() { + crds, err := ioutil.ReadDir(crdsDirectory) + if err != nil { + log.Fatal(err) + } + + for _, crd := range crds { + crdPath := filepath.Join(crdsDirectory, crd.Name()) + err := patchCRD(crdPath) + if err != nil { + log.Fatalf("Fail to patch crd %s: %s", crdPath, err.Error()) + } + } +} + +// patchCRD removes the element pointed by the `pathToRemove` if this path exists. +// It converts the YAML to JSON in order to use github.com/Jeffail/gabs which is +// a pretty convenient library to manipulate an arbitrary JSON. +func patchCRD(filename string) error { + bytes, err := ioutil.ReadFile(filename) + if err != nil { + return err + } + + jsonBytes, err := yaml.YAMLToJSON(bytes) + if err != nil { + return err + } + + jsonObj, err := gabs.ParseJSON(jsonBytes) + if err != nil { + return err + } + + // Skip if the element to remove does not exist (this is the case for the ES CRD) + if !jsonObj.ExistsP(pathToRemove) { + return nil + } + + err = jsonObj.DeleteP(pathToRemove) + if err != nil { + return err + } + + yamlBytes, err := yaml.JSONToYAML(jsonObj.Bytes()) + if err != nil { + return err + } + + // Append the --- yaml separator like the controller-gen + // https://github.com/kubernetes-sigs/controller-tools/blob/4752ed2de7d2fc1b6b18398bf26cf2ce6b53cd94/pkg/genall/genall.go#L106 + err = ioutil.WriteFile(filename, append([]byte("\n---\n"), yamlBytes...), 0644) + if err != nil { + return err + } + + return nil +} diff --git a/pkg/apis/apm/v1alpha1/apmserver_types.go b/pkg/apis/apm/v1alpha1/apmserver_types.go index 99b2b63061..745cf33f8d 100644 --- a/pkg/apis/apm/v1alpha1/apmserver_types.go +++ b/pkg/apis/apm/v1alpha1/apmserver_types.go @@ -64,14 +64,14 @@ const ( // ApmServerStatus defines the observed state of ApmServer type ApmServerStatus struct { - commonv1alpha1.ReconcilerStatus - Health ApmServerHealth `json:"health,omitempty"` + commonv1alpha1.ReconcilerStatus `json:",inline"` + Health ApmServerHealth `json:"health,omitempty"` // ExternalService is the name of the service the agents should connect to. ExternalService string `json:"service,omitempty"` // SecretTokenSecretName is the name of the Secret that contains the secret token SecretTokenSecretName string `json:"secretTokenSecret,omitempty"` // Association is the status of any auto-linking to Elasticsearch clusters. - Association commonv1alpha1.AssociationStatus + Association commonv1alpha1.AssociationStatus `json:"associationStatus,omitempty"` } // IsDegraded returns true if the current status is worse than the previous. @@ -79,11 +79,10 @@ func (as ApmServerStatus) IsDegraded(prev ApmServerStatus) bool { return prev.Health == ApmServerGreen && as.Health != ApmServerGreen } -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true // ApmServer is the Schema for the apmservers API -// +kubebuilder:categories=elastic +// +kubebuilder:resource:categories=elastic,shortName=apm // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" // +kubebuilder:printcolumn:name="nodes",type="integer",JSONPath=".status.availableNodes",description="Available nodes" @@ -93,9 +92,9 @@ type ApmServer struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ApmServerSpec `json:"spec,omitempty"` - Status ApmServerStatus `json:"status,omitempty"` - assocConf *commonv1alpha1.AssociationConf + Spec ApmServerSpec `json:"spec,omitempty"` + Status ApmServerStatus `json:"status,omitempty"` + assocConf *commonv1alpha1.AssociationConf `json:"-"` //nolint:govet } // +kubebuilder:object:root=true diff --git a/pkg/apis/apm/v1beta1/apmserver_types.go b/pkg/apis/apm/v1beta1/apmserver_types.go new file mode 100644 index 0000000000..c15a0239c6 --- /dev/null +++ b/pkg/apis/apm/v1beta1/apmserver_types.go @@ -0,0 +1,139 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + APMServerContainerName = "apm-server" + Kind = "ApmServer" +) + +// ApmServerSpec defines the desired state of ApmServer +type ApmServerSpec struct { + // Version represents the version of the APM Server + Version string `json:"version,omitempty"` + + // Image represents the docker image that will be used. + Image string `json:"image,omitempty"` + + // NodeCount defines how many nodes the Apm Server deployment must have. + NodeCount int32 `json:"nodeCount,omitempty"` + + // Config represents the APM configuration. + Config *commonv1beta1.Config `json:"config,omitempty"` + + // HTTP contains settings for HTTP. + HTTP commonv1beta1.HTTPConfig `json:"http,omitempty"` + + // ElasticsearchRef references an Elasticsearch resource in the Kubernetes cluster. + // If the namespace is not specified, the current resource namespace will be used. + ElasticsearchRef commonv1beta1.ObjectSelector `json:"elasticsearchRef,omitempty"` + + // PodTemplate can be used to propagate configuration to APM Server pods. + // This allows specifying custom annotations, labels, environment variables, + // affinity, resources, etc. for the pods created from this NodeSpec. + // +kubebuilder:validation:Optional + PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"` + + // SecureSettings references secrets containing secure settings, to be injected + // into the APM keystore on each node. + // Each individual key/value entry in the referenced secrets is considered as an + // individual secure setting to be injected. + // You can use the `entries` and `key` fields to consider only a subset of the secret + // entries and the `path` field to change the target path of a secret entry key. + // The secret must exist in the same namespace as the APM resource. + SecureSettings []commonv1beta1.SecretSource `json:"secureSettings,omitempty"` +} + +// ApmServerHealth expresses the status of the Apm Server instances. +type ApmServerHealth string + +const ( + // ApmServerRed means no instance is currently available. + ApmServerRed ApmServerHealth = "red" + // ApmServerGreen means at least one instance is available. + ApmServerGreen ApmServerHealth = "green" +) + +// ApmServerStatus defines the observed state of ApmServer +type ApmServerStatus struct { + commonv1beta1.ReconcilerStatus `json:",inline"` + Health ApmServerHealth `json:"health,omitempty"` + // ExternalService is the name of the service the agents should connect to. + ExternalService string `json:"service,omitempty"` + // SecretTokenSecretName is the name of the Secret that contains the secret token + SecretTokenSecretName string `json:"secretTokenSecret,omitempty"` + // Association is the status of any auto-linking to Elasticsearch clusters. + Association commonv1beta1.AssociationStatus `json:"associationStatus,omitempty"` +} + +// IsDegraded returns true if the current status is worse than the previous. +func (as ApmServerStatus) IsDegraded(prev ApmServerStatus) bool { + return prev.Health == ApmServerGreen && as.Health != ApmServerGreen +} + +// +kubebuilder:object:root=true + +// ApmServer is the Schema for the apmservers API +// +kubebuilder:resource:categories=elastic,shortName=apm +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" +// +kubebuilder:printcolumn:name="nodes",type="integer",JSONPath=".status.availableNodes",description="Available nodes" +// +kubebuilder:printcolumn:name="version",type="string",JSONPath=".spec.version",description="APM version" +// +kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:storageversion +type ApmServer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ApmServerSpec `json:"spec,omitempty"` + Status ApmServerStatus `json:"status,omitempty"` + assocConf *commonv1beta1.AssociationConf `json:"-"` //nolint:govet +} + +// +kubebuilder:object:root=true + +// ApmServerList contains a list of ApmServer +type ApmServerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ApmServer `json:"items"` +} + +func init() { + SchemeBuilder.Register(&ApmServer{}, &ApmServerList{}) +} + +// IsMarkedForDeletion returns true if the APM is going to be deleted +func (as *ApmServer) IsMarkedForDeletion() bool { + return !as.DeletionTimestamp.IsZero() +} + +func (as *ApmServer) ElasticsearchRef() commonv1beta1.ObjectSelector { + return as.Spec.ElasticsearchRef +} + +func (as *ApmServer) SecureSettings() []commonv1beta1.SecretSource { + return as.Spec.SecureSettings +} + +// Kind can technically be retrieved from metav1.Object, but there is a bug preventing us to retrieve it +// see https://github.com/kubernetes-sigs/controller-runtime/issues/406 +func (as *ApmServer) Kind() string { + return Kind +} + +func (as *ApmServer) AssociationConf() *commonv1beta1.AssociationConf { + return as.assocConf +} + +func (as *ApmServer) SetAssociationConf(assocConf *commonv1beta1.AssociationConf) { + as.assocConf = assocConf +} diff --git a/pkg/apis/apm/v1beta1/groupversion_info.go b/pkg/apis/apm/v1beta1/groupversion_info.go new file mode 100644 index 0000000000..9aadfc2191 --- /dev/null +++ b/pkg/apis/apm/v1beta1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1beta1 contains API Schema definitions for the apm v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=apm.k8s.elastic.co +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "apm.k8s.elastic.co", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/apm/v1beta1/zz_generated.deepcopy.go b/pkg/apis/apm/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..80dbba585f --- /dev/null +++ b/pkg/apis/apm/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,123 @@ +// +build !ignore_autogenerated + +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApmServer) DeepCopyInto(out *ApmServer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + if in.assocConf != nil { + in, out := &in.assocConf, &out.assocConf + *out = new(commonv1beta1.AssociationConf) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServer. +func (in *ApmServer) DeepCopy() *ApmServer { + if in == nil { + return nil + } + out := new(ApmServer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApmServer) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApmServerList) DeepCopyInto(out *ApmServerList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ApmServer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServerList. +func (in *ApmServerList) DeepCopy() *ApmServerList { + if in == nil { + return nil + } + out := new(ApmServerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApmServerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApmServerSpec) DeepCopyInto(out *ApmServerSpec) { + *out = *in + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = (*in).DeepCopy() + } + in.HTTP.DeepCopyInto(&out.HTTP) + out.ElasticsearchRef = in.ElasticsearchRef + in.PodTemplate.DeepCopyInto(&out.PodTemplate) + if in.SecureSettings != nil { + in, out := &in.SecureSettings, &out.SecureSettings + *out = make([]commonv1beta1.SecretSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServerSpec. +func (in *ApmServerSpec) DeepCopy() *ApmServerSpec { + if in == nil { + return nil + } + out := new(ApmServerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApmServerStatus) DeepCopyInto(out *ApmServerStatus) { + *out = *in + out.ReconcilerStatus = in.ReconcilerStatus +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServerStatus. +func (in *ApmServerStatus) DeepCopy() *ApmServerStatus { + if in == nil { + return nil + } + out := new(ApmServerStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/common/v1alpha1/config.go b/pkg/apis/common/v1alpha1/config.go index 6b8d41f518..f29d0d3a48 100644 --- a/pkg/apis/common/v1alpha1/config.go +++ b/pkg/apis/common/v1alpha1/config.go @@ -16,7 +16,7 @@ var CfgOptions = []ucfg.Option{ucfg.PathSep(".")} // Config represents untyped YAML configuration inside a spec. type Config struct { // This field exists to work around https://github.com/kubernetes-sigs/kubebuilder/issues/528 - Data map[string]interface{} + Data map[string]interface{} `json:"-"` } // NewConfig constructs a Config with the given unstructured configuration data. diff --git a/pkg/apis/common/v1beta1/association.go b/pkg/apis/common/v1beta1/association.go new file mode 100644 index 0000000000..dc0003f750 --- /dev/null +++ b/pkg/apis/common/v1beta1/association.go @@ -0,0 +1,113 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// AssociationStatus is the status of an association resource. +type AssociationStatus string + +const ( + AssociationUnknown AssociationStatus = "" + AssociationPending AssociationStatus = "Pending" + AssociationEstablished AssociationStatus = "Established" + AssociationFailed AssociationStatus = "Failed" +) + +// Associated interface represents a Elastic stack application that is associated with an Elasticsearch cluster. +// An associated object needs some credentials to establish a connection to the Elasticsearch cluster and usually it +// offers a keystore which in ECK is represented with an underlying Secret. +// Kibana and the APM server are two examples of associated objects. +// +kubebuilder:object:generate=false +type Associated interface { + metav1.Object + runtime.Object + ElasticsearchRef() ObjectSelector + AssociationConf() *AssociationConf +} + +// Associator describes an object that allows its association to be set. +// +kubebuilder:object:generate=false +type Associator interface { + metav1.Object + runtime.Object + SetAssociationConf(*AssociationConf) +} + +// AssociationConf holds the association configuration of an Elasticsearch cluster. +type AssociationConf struct { + AuthSecretName string `json:"authSecretName"` + AuthSecretKey string `json:"authSecretKey"` + CACertProvided bool `json:"caCertProvided"` + CASecretName string `json:"caSecretName"` + URL string `json:"url"` +} + +// IsConfigured returns true if all the fields are set. +func (ac *AssociationConf) IsConfigured() bool { + return ac.AuthIsConfigured() && ac.CAIsConfigured() && ac.URLIsConfigured() +} + +// AuthIsConfigured returns true if all the auth fields are set. +func (ac *AssociationConf) AuthIsConfigured() bool { + if ac == nil { + return false + } + return ac.AuthSecretName != "" && ac.AuthSecretKey != "" +} + +// CAIsConfigured returns true if the CA field is set. +func (ac *AssociationConf) CAIsConfigured() bool { + if ac == nil { + return false + } + return ac.CASecretName != "" +} + +// URLIsConfigured returns true if the URL field is set. +func (ac *AssociationConf) URLIsConfigured() bool { + if ac == nil { + return false + } + return ac.URL != "" +} + +func (ac *AssociationConf) GetAuthSecretName() string { + if ac == nil { + return "" + } + return ac.AuthSecretName +} + +func (ac *AssociationConf) GetAuthSecretKey() string { + if ac == nil { + return "" + } + return ac.AuthSecretKey +} + +func (ac *AssociationConf) GetCACertProvided() bool { + if ac == nil { + return false + } + return ac.CACertProvided +} + +func (ac *AssociationConf) GetCASecretName() string { + if ac == nil { + return "" + } + return ac.CASecretName +} + +func (ac *AssociationConf) GetURL() string { + if ac == nil { + return "" + } + return ac.URL +} diff --git a/pkg/apis/common/v1beta1/association_test.go b/pkg/apis/common/v1beta1/association_test.go new file mode 100644 index 0000000000..02fd907281 --- /dev/null +++ b/pkg/apis/common/v1beta1/association_test.go @@ -0,0 +1,77 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAssociationConfIsConfigured(t *testing.T) { + tests := []struct { + name string + assocConf *AssociationConf + want bool + }{ + { + name: "nil object", + want: false, + }, + { + name: "missing URL", + assocConf: &AssociationConf{ + AuthSecretName: "auth-secret", + AuthSecretKey: "elastic", + CASecretName: "ca-secret", + }, + want: false, + }, + { + name: "missing auth secret name", + assocConf: &AssociationConf{ + AuthSecretKey: "elastic", + CASecretName: "ca-secret", + URL: "https://my-es.svc", + }, + want: false, + }, + { + name: "missing auth secret key", + assocConf: &AssociationConf{ + AuthSecretName: "auth-secret", + CASecretName: "ca-secret", + URL: "https://my-es.svc", + }, + want: false, + }, + { + name: "missing CA secret name", + assocConf: &AssociationConf{ + AuthSecretName: "auth-secret", + AuthSecretKey: "elastic", + URL: "https://my-es.svc", + }, + want: false, + }, + { + name: "correctly configured", + assocConf: &AssociationConf{ + AuthSecretName: "auth-secret", + AuthSecretKey: "elastic", + CASecretName: "ca-secret", + URL: "https://my-es.svc", + }, + want: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := tt.assocConf.IsConfigured() + require.Equal(t, tt.want, got) + }) + } +} diff --git a/pkg/apis/common/v1beta1/common.go b/pkg/apis/common/v1beta1/common.go new file mode 100644 index 0000000000..1dc5ff3f9c --- /dev/null +++ b/pkg/apis/common/v1beta1/common.go @@ -0,0 +1,153 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "reflect" + + v1 "k8s.io/api/core/v1" + "k8s.io/api/policy/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// ReconcilerStatus represents status information about desired/available nodes. +type ReconcilerStatus struct { + AvailableNodes int `json:"availableNodes,omitempty"` +} + +// SecretRef reference a secret by name. +type SecretRef struct { + SecretName string `json:"secretName,omitempty"` +} + +// ObjectSelector allows to specify a reference to an object across namespace boundaries. +type ObjectSelector struct { + Name string `json:"name"` + Namespace string `json:"namespace,omitempty"` +} + +// NamespacedName is a convenience method to turn an ObjectSelector into a NamespacedName. +func (s ObjectSelector) NamespacedName() types.NamespacedName { + return types.NamespacedName{ + Name: s.Name, + Namespace: s.Namespace, + } +} + +// IsDefined checks if the object selector is not nil and has a name. +// Namespace is not mandatory as it may be inherited by the parent object. +func (s *ObjectSelector) IsDefined() bool { + return s != nil && s.Name != "" +} + +// HTTPConfig configures an HTTP-based service. +type HTTPConfig struct { + // Service is a template for the Kubernetes Service + Service ServiceTemplate `json:"service,omitempty"` + // TLS describe additional options to consider when generating HTTP TLS certificates. + TLS TLSOptions `json:"tls,omitempty"` +} + +// Scheme returns the scheme for this HTTP config +func (http HTTPConfig) Scheme() string { + if http.TLS.Enabled() { + return "https" + } + return "http" +} + +type TLSOptions struct { + // SelfSignedCertificate define options to apply to self-signed certificate + // managed by the operator. + SelfSignedCertificate *SelfSignedCertificate `json:"selfSignedCertificate,omitempty"` + + // Certificate is a reference to a secret that contains the certificate and private key to be used. + // + // The secret should have the following content: + // + // - `ca.crt`: The certificate authority (optional) + // - `tls.crt`: The certificate (or a chain). + // - `tls.key`: The private key to the first certificate in the certificate chain. + Certificate SecretRef `json:"certificate,omitempty"` +} + +// Enabled returns true when TLS is enabled based on this option struct. +func (tls TLSOptions) Enabled() bool { + selfSigned := tls.SelfSignedCertificate + return selfSigned == nil || !selfSigned.Disabled || tls.Certificate.SecretName != "" +} + +type SelfSignedCertificate struct { + // SubjectAlternativeNames is a list of SANs to include in the HTTP TLS certificates. + // For example: a wildcard DNS to expose the cluster. + SubjectAlternativeNames []SubjectAlternativeName `json:"subjectAltNames,omitempty"` + // Disabled turns off the provisioning of self-signed HTTP TLS certificates. + Disabled bool `json:"disabled,omitempty"` +} + +type SubjectAlternativeName struct { + DNS string `json:"dns,omitempty"` + IP string `json:"ip,omitempty"` +} + +// ServiceTemplate describes the data a service should have when created from a template +type ServiceTemplate struct { + // ObjectMeta is metadata for the service. + // The name and namespace provided here is managed by ECK and will be ignored. + // +kubebuilder:validation:Optional + ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the behavior of the service. + // +kubebuilder:validation:Optional + Spec v1.ServiceSpec `json:"spec,omitempty"` +} + +// DefaultPodDisruptionBudgetMaxUnavailable is the default max unavailable pods in a PDB. +var DefaultPodDisruptionBudgetMaxUnavailable = intstr.FromInt(1) + +// PodDisruptionBudgetTemplate contains a template for creating a PodDisruptionBudget. +type PodDisruptionBudgetTemplate struct { + // ObjectMeta is metadata for the service. + // The name and namespace provided here is managed by ECK and will be ignored. + // +kubebuilder:validation:Optional + ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec of the desired behavior of the PodDisruptionBudget + // +kubebuilder:validation:Optional + Spec v1beta1.PodDisruptionBudgetSpec `json:"spec,omitempty"` +} + +// IsDisabled returns true if the PodDisruptionBudget is explicitly disabled (not nil, but empty). +func (p *PodDisruptionBudgetTemplate) IsDisabled() bool { + return reflect.DeepEqual(p, &PodDisruptionBudgetTemplate{}) +} + +type SecretSource struct { + // Name of the secret in the pod's namespace to use. + // More info: https://kubernetes.io/docs/concepts/storage/volumes#secret + SecretName string `json:"secretName"` + // If unspecified, each key-value pair in the Data field of the referenced + // Secret will be projected into the volume as a file whose name is the + // key and content is the value. If specified, the listed keys will be + // projected into the specified paths, and unlisted keys will not be + // present. + // +kubebuilder:validation:Optional + Entries []KeyToPath `json:"entries,omitempty"` +} + +// Maps a string key to a path within a volume. +type KeyToPath struct { + // The key to project. + Key string `json:"key"` + + // The relative path of the file to map the key to. + // May not be an absolute path. + // May not contain the path element '..'. + // May not start with the string '..'. + // +kubebuilder:validation:Optional + Path string `json:"path,omitempty"` +} diff --git a/pkg/apis/common/v1beta1/common_test.go b/pkg/apis/common/v1beta1/common_test.go new file mode 100644 index 0000000000..7139232d5d --- /dev/null +++ b/pkg/apis/common/v1beta1/common_test.go @@ -0,0 +1,134 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import "testing" + +func TestTLSOptions_Enabled(t *testing.T) { + type fields struct { + SelfSignedCertificate *SelfSignedCertificate + Certificate SecretRef + } + tests := []struct { + name string + fields fields + want bool + }{ + { + name: "disabled: no custom cert and self-signed disabled", + fields: fields{ + SelfSignedCertificate: &SelfSignedCertificate{ + Disabled: true, + }, + Certificate: SecretRef{}, + }, + want: false, + }, + { + name: "enabled: custom certs and self-signed disabled", + fields: fields{ + SelfSignedCertificate: &SelfSignedCertificate{ + Disabled: true, + }, + Certificate: SecretRef{ + SecretName: "my-custom-certs", + }, + }, + want: true, + }, + { + name: "enabled: by default", + fields: fields{}, + want: true, + }, + { + name: "enabled: via self-signed certificates", + fields: fields{ + SelfSignedCertificate: &SelfSignedCertificate{ + SubjectAlternativeNames: []SubjectAlternativeName{}, + Disabled: false, + }, + Certificate: SecretRef{}, + }, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tls := TLSOptions{ + SelfSignedCertificate: tt.fields.SelfSignedCertificate, + Certificate: tt.fields.Certificate, + } + if got := tls.Enabled(); got != tt.want { + t.Errorf("TLSOptions.Enabled() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestHTTPConfig_Scheme(t *testing.T) { + type fields struct { + TLS TLSOptions + } + tests := []struct { + name string + fields fields + want string + }{ + { + name: "enabled", + fields: fields{ + TLS: TLSOptions{ + SelfSignedCertificate: &SelfSignedCertificate{ + Disabled: false, + }, + }, + }, + want: "https", + }, + { + name: "enabled: custom certs and self-signed disabled", + fields: fields{ + TLS: TLSOptions{ + SelfSignedCertificate: &SelfSignedCertificate{ + Disabled: true, + }, + Certificate: SecretRef{ + SecretName: "my-custom-certs", + }, + }, + }, + want: "https", + }, + { + name: "disabled", + fields: fields{ + TLS: TLSOptions{ + SelfSignedCertificate: &SelfSignedCertificate{ + Disabled: true, + }, + }, + }, + want: "http", + }, + { + name: "default", + fields: fields{ + TLS: TLSOptions{}, + }, + want: "https", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + http := HTTPConfig{ + TLS: tt.fields.TLS, + } + if got := http.Scheme(); got != tt.want { + t.Errorf("Scheme() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/apis/common/v1beta1/config.go b/pkg/apis/common/v1beta1/config.go new file mode 100644 index 0000000000..a26687eeb8 --- /dev/null +++ b/pkg/apis/common/v1beta1/config.go @@ -0,0 +1,59 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "encoding/json" + + ucfg "github.com/elastic/go-ucfg" +) + +// CfgOptions are config options for YAML config. Currently contains only support for dotted keys. +var CfgOptions = []ucfg.Option{ucfg.PathSep(".")} + +// Config represents untyped YAML configuration inside a spec. +type Config struct { + // This field exists to work around https://github.com/kubernetes-sigs/kubebuilder/issues/528 + Data map[string]interface{} `json:"-"` +} + +// NewConfig constructs a Config with the given unstructured configuration data. +func NewConfig(cfg map[string]interface{}) Config { + return Config{Data: cfg} +} + +// MarshalJSON implements the Marshaler interface. +func (c *Config) MarshalJSON() ([]byte, error) { + return json.Marshal(c.Data) +} + +// UnmarshalJSON implements the Unmarshaler interface. +func (c *Config) UnmarshalJSON(data []byte) error { + var out map[string]interface{} + err := json.Unmarshal(data, &out) + if err != nil { + return err + } + c.Data = out + return nil +} + +// DeepCopyInto is an ~autogenerated~ deepcopy function, copying the receiver, writing into out. in must be non-nil. +// This exists here to work around https://github.com/kubernetes/code-generator/issues/50 +func (c *Config) DeepCopyInto(out *Config) { + bytes, err := json.Marshal(c.Data) + if err != nil { + // we assume that it marshals cleanly because otherwise the resource would not have been + // created in the API server + panic(err) + } + var copy map[string]interface{} + err = json.Unmarshal(bytes, ©) + if err != nil { + // we assume again optimistically because we just marshalled that the round trip works as well + panic(err) + } + out.Data = copy +} diff --git a/pkg/apis/common/v1beta1/config_test.go b/pkg/apis/common/v1beta1/config_test.go new file mode 100644 index 0000000000..27f15d6d4f --- /dev/null +++ b/pkg/apis/common/v1beta1/config_test.go @@ -0,0 +1,83 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "testing" + + "github.com/go-test/deep" +) + +var testFixture = Config{ + Data: map[string]interface{}{ + "a": map[string]interface{}{ + "b": map[string]interface{}{ + "c": 1.0, + }, + "d": 1, + }, + "a.b.foo": "bar", + "e": []interface{}{1, 2, 3}, + "f": true, + }, +} + +var expectedJSONized = Config{ + Data: map[string]interface{}{ + "a": map[string]interface{}{ + "b": map[string]interface{}{ + "c": 1.0, + }, + "d": float64(1), + }, + "a.b.foo": "bar", + "e": []interface{}{float64(1), float64(2), float64(3)}, + "f": true, + }, +} + +func TestConfig_DeepCopyInto(t *testing.T) { + tests := []struct { + name string + in Config + expected Config + }{ + { + name: "deep copy via JSON roundtrip changes some types", + in: testFixture, + expected: expectedJSONized, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var out Config + tt.in.DeepCopyInto(&out) + if diff := deep.Equal(out, tt.expected); diff != nil { + t.Error(diff) + } + }) + } +} + +func TestConfig_DeepCopy(t *testing.T) { + tests := []struct { + name string + in Config + want Config + }{ + { + name: "deep copy via JSON roundtrip changes some types", + in: testFixture, + want: expectedJSONized, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if diff := deep.Equal(tt.in.DeepCopy(), &tt.want); diff != nil { + t.Error(diff) + } + }) + } +} diff --git a/pkg/apis/common/v1beta1/groupversion_info.go b/pkg/apis/common/v1beta1/groupversion_info.go new file mode 100644 index 0000000000..af98dcb24b --- /dev/null +++ b/pkg/apis/common/v1beta1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1beta1 contains API Schema definitions for the apm v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=common.k8s.elastic.co +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "common.k8s.elastic.co", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/common/v1beta1/zz_generated.deepcopy.go b/pkg/apis/common/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..0e7d005ea2 --- /dev/null +++ b/pkg/apis/common/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,223 @@ +// +build !ignore_autogenerated + +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import () + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AssociationConf) DeepCopyInto(out *AssociationConf) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AssociationConf. +func (in *AssociationConf) DeepCopy() *AssociationConf { + if in == nil { + return nil + } + out := new(AssociationConf) + in.DeepCopyInto(out) + return out +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. +func (in *Config) DeepCopy() *Config { + if in == nil { + return nil + } + out := new(Config) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPConfig) DeepCopyInto(out *HTTPConfig) { + *out = *in + in.Service.DeepCopyInto(&out.Service) + in.TLS.DeepCopyInto(&out.TLS) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPConfig. +func (in *HTTPConfig) DeepCopy() *HTTPConfig { + if in == nil { + return nil + } + out := new(HTTPConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeyToPath) DeepCopyInto(out *KeyToPath) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeyToPath. +func (in *KeyToPath) DeepCopy() *KeyToPath { + if in == nil { + return nil + } + out := new(KeyToPath) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObjectSelector) DeepCopyInto(out *ObjectSelector) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectSelector. +func (in *ObjectSelector) DeepCopy() *ObjectSelector { + if in == nil { + return nil + } + out := new(ObjectSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodDisruptionBudgetTemplate) DeepCopyInto(out *PodDisruptionBudgetTemplate) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodDisruptionBudgetTemplate. +func (in *PodDisruptionBudgetTemplate) DeepCopy() *PodDisruptionBudgetTemplate { + if in == nil { + return nil + } + out := new(PodDisruptionBudgetTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReconcilerStatus) DeepCopyInto(out *ReconcilerStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReconcilerStatus. +func (in *ReconcilerStatus) DeepCopy() *ReconcilerStatus { + if in == nil { + return nil + } + out := new(ReconcilerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecretRef) DeepCopyInto(out *SecretRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretRef. +func (in *SecretRef) DeepCopy() *SecretRef { + if in == nil { + return nil + } + out := new(SecretRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecretSource) DeepCopyInto(out *SecretSource) { + *out = *in + if in.Entries != nil { + in, out := &in.Entries, &out.Entries + *out = make([]KeyToPath, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretSource. +func (in *SecretSource) DeepCopy() *SecretSource { + if in == nil { + return nil + } + out := new(SecretSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SelfSignedCertificate) DeepCopyInto(out *SelfSignedCertificate) { + *out = *in + if in.SubjectAlternativeNames != nil { + in, out := &in.SubjectAlternativeNames, &out.SubjectAlternativeNames + *out = make([]SubjectAlternativeName, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelfSignedCertificate. +func (in *SelfSignedCertificate) DeepCopy() *SelfSignedCertificate { + if in == nil { + return nil + } + out := new(SelfSignedCertificate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceTemplate) DeepCopyInto(out *ServiceTemplate) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceTemplate. +func (in *ServiceTemplate) DeepCopy() *ServiceTemplate { + if in == nil { + return nil + } + out := new(ServiceTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubjectAlternativeName) DeepCopyInto(out *SubjectAlternativeName) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubjectAlternativeName. +func (in *SubjectAlternativeName) DeepCopy() *SubjectAlternativeName { + if in == nil { + return nil + } + out := new(SubjectAlternativeName) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TLSOptions) DeepCopyInto(out *TLSOptions) { + *out = *in + if in.SelfSignedCertificate != nil { + in, out := &in.SelfSignedCertificate, &out.SelfSignedCertificate + *out = new(SelfSignedCertificate) + (*in).DeepCopyInto(*out) + } + out.Certificate = in.Certificate +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSOptions. +func (in *TLSOptions) DeepCopy() *TLSOptions { + if in == nil { + return nil + } + out := new(TLSOptions) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go b/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go index c3d149c2bc..5702c8ac29 100644 --- a/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go +++ b/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go @@ -197,9 +197,13 @@ const ( // ElasticsearchStatus defines the observed state of Elasticsearch type ElasticsearchStatus struct { - commonv1alpha1.ReconcilerStatus - Health ElasticsearchHealth `json:"health,omitempty"` - Phase ElasticsearchOrchestrationPhase `json:"phase,omitempty"` + commonv1alpha1.ReconcilerStatus `json:",inline"` + Health ElasticsearchHealth `json:"health,omitempty"` + Phase ElasticsearchOrchestrationPhase `json:"phase,omitempty"` + ClusterUUID string `json:"clusterUUID,omitempty"` + MasterNode string `json:"masterNode,omitempty"` + ExternalService string `json:"service,omitempty"` + ZenDiscovery ZenDiscoveryStatus `json:"zenDiscovery,omitempty"` } type ZenDiscoveryStatus struct { @@ -214,9 +218,8 @@ func (es ElasticsearchStatus) IsDegraded(prev ElasticsearchStatus) bool { // +kubebuilder:object:root=true // Elasticsearch is the Schema for the elasticsearches API +// +kubebuilder:resource:categories=elastic,shortName=es // +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=es -// +kubebuilder:categories=elastic // +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" // +kubebuilder:printcolumn:name="nodes",type="integer",JSONPath=".status.availableNodes",description="Available nodes" // +kubebuilder:printcolumn:name="version",type="string",JSONPath=".spec.version",description="Elasticsearch version" diff --git a/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go index 48d59aa92f..a2e69fa357 100644 --- a/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go @@ -170,6 +170,7 @@ func (in *ElasticsearchSpec) DeepCopy() *ElasticsearchSpec { func (in *ElasticsearchStatus) DeepCopyInto(out *ElasticsearchStatus) { *out = *in out.ReconcilerStatus = in.ReconcilerStatus + out.ZenDiscovery = in.ZenDiscovery } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchStatus. diff --git a/pkg/apis/elasticsearch/v1beta1/elasticsearch_config.go b/pkg/apis/elasticsearch/v1beta1/elasticsearch_config.go new file mode 100644 index 0000000000..573c384d60 --- /dev/null +++ b/pkg/apis/elasticsearch/v1beta1/elasticsearch_config.go @@ -0,0 +1,61 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + ucfg "github.com/elastic/go-ucfg" +) + +const ( + NodeData = "node.data" + NodeIngest = "node.ingest" + NodeMaster = "node.master" + NodeML = "node.ml" +) + +// ClusterSettings is the cluster node in elasticsearch.yml. +type ClusterSettings struct { + InitialMasterNodes []string `config:"initial_master_nodes"` +} + +// Node is the node section in elasticsearch.yml. +type Node struct { + Master bool `config:"master"` + Data bool `config:"data"` + Ingest bool `config:"ingest"` + ML bool `config:"ml"` +} + +// ElasticsearchSettings is a typed subset of elasticsearch.yml for purposes of the operator. +type ElasticsearchSettings struct { + Node Node `config:"node"` + Cluster ClusterSettings `config:"cluster"` +} + +// DefaultCfg is an instance of ElasticsearchSettings with defaults set as they are in Elasticsearch. +var DefaultCfg = ElasticsearchSettings{ + Node: Node{ + Master: true, + Data: true, + Ingest: true, + ML: true, + }, +} + +// Unpack unpacks Config into a typed subset. +func UnpackConfig(c *v1beta1.Config) (ElasticsearchSettings, error) { + esSettings := DefaultCfg // defensive copy + if c == nil { + // make this nil safe to allow a ptr value to work around Json serialization issues + return esSettings, nil + } + config, err := ucfg.NewFrom(c.Data, v1beta1.CfgOptions...) + if err != nil { + return esSettings, err + } + err = config.Unpack(&esSettings, v1beta1.CfgOptions...) + return esSettings, err +} diff --git a/pkg/apis/elasticsearch/v1beta1/elasticsearch_config_test.go b/pkg/apis/elasticsearch/v1beta1/elasticsearch_config_test.go new file mode 100644 index 0000000000..db2d5bdbac --- /dev/null +++ b/pkg/apis/elasticsearch/v1beta1/elasticsearch_config_test.go @@ -0,0 +1,202 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "testing" + + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/go-test/deep" + "github.com/stretchr/testify/require" +) + +func TestConfig_RoleDefaults(t *testing.T) { + type args struct { + c2 v1beta1.Config + } + tests := []struct { + name string + c v1beta1.Config + args args + want bool + }{ + { + name: "empty is equal", + c: v1beta1.Config{}, + args: args{}, + want: true, + }, + { + name: "same is equal", + c: v1beta1.Config{ + Data: map[string]interface{}{ + NodeMaster: true, + }, + }, + args: args{ + c2: v1beta1.Config{ + Data: map[string]interface{}{ + NodeMaster: true, + }, + }, + }, + want: true, + }, + { + name: "detect differences", + c: v1beta1.Config{ + Data: map[string]interface{}{ + NodeMaster: false, + NodeData: true, + }, + }, + args: args{ + c2: v1beta1.Config{ + Data: map[string]interface{}{ + NodeData: true, + }, + }, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c1, err := UnpackConfig(&tt.c) + require.NoError(t, err) + c2, err := UnpackConfig(&tt.args.c2) + require.NoError(t, err) + if got := c1.Node == c2.Node; got != tt.want { + t.Errorf("Config.EqualRoles() = %v, want %v", got, tt.want) + } + }) + } +} + +var testFixture = v1beta1.Config{ + Data: map[string]interface{}{ + "a": map[string]interface{}{ + "b": map[string]interface{}{ + "c": 1.0, + }, + "d": 1, + }, + "a.b.foo": "bar", + "e": []interface{}{1, 2, 3}, + "f": true, + }, +} + +var expectedJSONized = v1beta1.Config{ + Data: map[string]interface{}{ + "a": map[string]interface{}{ + "b": map[string]interface{}{ + "c": 1.0, + }, + "d": float64(1), + }, + "a.b.foo": "bar", + "e": []interface{}{float64(1), float64(2), float64(3)}, + "f": true, + }, +} + +func TestConfig_DeepCopyInto(t *testing.T) { + tests := []struct { + name string + in v1beta1.Config + expected v1beta1.Config + }{ + { + name: "deep copy via JSON roundtrip changes some types", + in: testFixture, + expected: expectedJSONized, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var out v1beta1.Config + tt.in.DeepCopyInto(&out) + if diff := deep.Equal(out, tt.expected); diff != nil { + t.Error(diff) + } + }) + } +} + +func TestConfig_DeepCopy(t *testing.T) { + tests := []struct { + name string + in v1beta1.Config + want v1beta1.Config + }{ + { + name: "deep copy via JSON roundtrip changes some types", + in: testFixture, + want: expectedJSONized, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if diff := deep.Equal(tt.in.DeepCopy(), &tt.want); diff != nil { + t.Error(diff) + } + }) + } +} + +func TestConfig_Unpack(t *testing.T) { + tests := []struct { + name string + args *v1beta1.Config + want ElasticsearchSettings + wantErr bool + }{ + { + name: "happy path", + args: &v1beta1.Config{ + Data: map[string]interface{}{ + "node": map[string]interface{}{ + "master": false, + "data": true, + }, + "cluster": map[string]interface{}{ + "initial_master_nodes": []string{"a", "b"}, + }, + }, + }, + want: ElasticsearchSettings{ + Node: Node{ + Master: false, + Data: true, + Ingest: true, + ML: true, + }, + Cluster: ClusterSettings{ + InitialMasterNodes: []string{"a", "b"}, + }, + }, + wantErr: false, + }, + { + name: "Unpack is nil safe", + args: nil, + want: DefaultCfg, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := UnpackConfig(tt.args) + if (err != nil) != tt.wantErr { + t.Errorf("Config.Unpack() error = %v, wantErr %v", err, tt.wantErr) + return + } + if diff := deep.Equal(tt.want, got); diff != nil { + t.Error(diff) + } + }) + } +} diff --git a/pkg/apis/elasticsearch/v1beta1/elasticsearch_types.go b/pkg/apis/elasticsearch/v1beta1/elasticsearch_types.go new file mode 100644 index 0000000000..444e8f85a7 --- /dev/null +++ b/pkg/apis/elasticsearch/v1beta1/elasticsearch_types.go @@ -0,0 +1,259 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ElasticsearchContainerName = "elasticsearch" + Kind = "Elasticsearch" +) + +// ElasticsearchSpec defines the desired state of Elasticsearch +type ElasticsearchSpec struct { + // Version represents the version of the stack + Version string `json:"version,omitempty"` + + // Image represents the docker image that will be used. + Image string `json:"image,omitempty"` + + // SetVMMaxMapCount indicates whether an init container should be used to ensure that the `vm.max_map_count` + // is set according to https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html. + // Setting this to true requires the kubelet to allow running privileged containers. + // Defaults to true if not specified. To be disabled, it must be explicitly set to false. + SetVMMaxMapCount *bool `json:"setVmMaxMapCount,omitempty"` + + // HTTP contains settings for HTTP. + HTTP commonv1beta1.HTTPConfig `json:"http,omitempty"` + + // Nodes represents a list of groups of nodes with the same configuration to be part of the cluster + Nodes []NodeSpec `json:"nodes,omitempty"` + + // UpdateStrategy specifies how updates to the cluster should be performed. + UpdateStrategy UpdateStrategy `json:"updateStrategy,omitempty"` + + // PodDisruptionBudget allows full control of the default pod disruption budget. + // + // The default budget selects all cluster pods and sets maxUnavailable to 1. + // To disable it entirely, set to the empty value (`{}` in YAML). + // +kubebuilder:validation:Optional + PodDisruptionBudget *commonv1beta1.PodDisruptionBudgetTemplate `json:"podDisruptionBudget,omitempty"` + + // SecureSettings references secrets containing secure settings, to be injected + // into Elasticsearch keystore on each node. + // Each individual key/value entry in the referenced secrets is considered as an + // individual secure setting to be injected. + // You can use the `entries` and `key` fields to consider only a subset of the secret + // entries and the `path` field to change the target path of a secret entry key. + // The secret must exist in the same namespace as the Elasticsearch resource. + SecureSettings []commonv1beta1.SecretSource `json:"secureSettings,omitempty"` +} + +// NodeCount returns the total number of nodes of the Elasticsearch cluster +func (es ElasticsearchSpec) NodeCount() int32 { + count := int32(0) + for _, topoElem := range es.Nodes { + count += topoElem.NodeCount + } + return count +} + +// NodeSpec defines a common topology for a set of Elasticsearch nodes +type NodeSpec struct { + // Name is a logical name for this set of nodes. Used as a part of the managed Elasticsearch node.name setting. + // +kubebuilder:validation:Pattern=[a-zA-Z0-9-]+ + // +kubebuilder:validation:MaxLength=23 + Name string `json:"name"` + + // Config represents Elasticsearch configuration. + Config *commonv1beta1.Config `json:"config,omitempty"` + + // NodeCount defines how many nodes have this topology + NodeCount int32 `json:"nodeCount,omitempty"` + + // PodTemplate can be used to propagate configuration to Elasticsearch pods. + // This allows specifying custom annotations, labels, environment variables, + // volumes, affinity, resources, etc. for the pods created from this NodeSpec. + // +kubebuilder:validation:Optional + PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"` + + // VolumeClaimTemplates is a list of claims that pods are allowed to reference. + // Every claim in this list must have at least one matching (by name) volumeMount in one + // container in the template. A claim in this list takes precedence over + // any volumes in the template, with the same name. + // TODO: Define the behavior if a claim already exists with the same name. + // TODO: define special behavior based on claim metadata.name. (e.g data / logs volumes) + // +kubebuilder:validation:Optional + VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` +} + +// GetESContainerTemplate returns the Elasticsearch container (if set) from the NodeSpec's PodTemplate +func (n NodeSpec) GetESContainerTemplate() *corev1.Container { + for _, c := range n.PodTemplate.Spec.Containers { + if c.Name == ElasticsearchContainerName { + return &c + } + } + return nil +} + +// UpdateStrategy specifies how updates to the cluster should be performed. +type UpdateStrategy struct { + // ChangeBudget is the change budget that should be used when performing mutations to the cluster. + ChangeBudget *ChangeBudget `json:"changeBudget,omitempty"` +} + +// ResolveChangeBudget resolves the optional ChangeBudget into the user-provided one or a defaulted one. +func (s UpdateStrategy) ResolveChangeBudget() ChangeBudget { + if s.ChangeBudget != nil { + return *s.ChangeBudget + } + + return DefaultChangeBudget +} + +// ChangeBudget defines how Pods in a single group should be updated. +type ChangeBudget struct { + // TODO: MaxUnavailable and MaxSurge would be great to have as intstrs, but due to + // https://github.com/kubernetes-sigs/kubebuilder/issues/442 this is not currently an option. + + // MaxUnavailable is the maximum number of pods that can be unavailable during the update. + // Value can be an absolute number (ex: 5) or a percentage of total pods at the start of update (ex: 10%). + // Absolute number is calculated from percentage by rounding down. + // This can not be 0 if MaxSurge is 0 if you want automatic rolling changes to be applied. + // By default, a fixed value of 0 is used. + // Example: when this is set to 30%, the group can be scaled down by 30% + // immediately when the rolling update starts. Once new pods are ready, the group + // can be scaled down further, followed by scaling up the group, ensuring + // that at least 70% of the target number of pods are available at all times + // during the update. + MaxUnavailable int `json:"maxUnavailable"` + + // MaxSurge is the maximum number of pods that can be scheduled above the original number of + // pods. + // By default, a fixed value of 1 is used. + // Value can be an absolute number (ex: 5) or a percentage of total pods at + // the start of the update (ex: 10%). This can not be 0 if MaxUnavailable is 0 if you want automatic rolling + // updates to be applied. + // Absolute number is calculated from percentage by rounding up. + // Example: when this is set to 30%, the new group can be scaled up by 30% + // immediately when the rolling update starts. Once old pods have been killed, + // new group can be scaled up further, ensuring that total number of pods running + // at any time during the update is at most 130% of the target number of pods. + MaxSurge int `json:"maxSurge"` +} + +// DefaultChangeBudget is used when no change budget is provided. It might not be the most effective, but should work in +// every case +var DefaultChangeBudget = ChangeBudget{ + MaxSurge: 1, + MaxUnavailable: 0, +} + +// ElasticsearchHealth is the health of the cluster as returned by the health API. +type ElasticsearchHealth string + +// Possible traffic light states Elasticsearch health can have. +const ( + ElasticsearchRedHealth ElasticsearchHealth = "red" + ElasticsearchYellowHealth ElasticsearchHealth = "yellow" + ElasticsearchGreenHealth ElasticsearchHealth = "green" + ElasticsearchUnknownHealth ElasticsearchHealth = "unknown" +) + +var elasticsearchHealthOrder = map[ElasticsearchHealth]int{ + ElasticsearchRedHealth: 1, + ElasticsearchYellowHealth: 2, + ElasticsearchGreenHealth: 3, +} + +// Less for ElasticsearchHealth means green > yellow > red +func (h ElasticsearchHealth) Less(other ElasticsearchHealth) bool { + l := elasticsearchHealthOrder[h] + r := elasticsearchHealthOrder[other] + // 0 is not found/unknown and less is not defined for that + return l != 0 && r != 0 && l < r +} + +// ElasticsearchOrchestrationPhase is the phase Elasticsearch is in from the controller point of view. +type ElasticsearchOrchestrationPhase string + +const ( + // ElasticsearchReadyPhase is operating at the desired spec. + ElasticsearchReadyPhase ElasticsearchOrchestrationPhase = "Ready" + // ElasticsearchApplyingChangesPhase controller is working towards a desired state, cluster can be unavailable. + ElasticsearchApplyingChangesPhase ElasticsearchOrchestrationPhase = "ApplyingChanges" + // ElasticsearchMigratingDataPhase Elasticsearch is currently migrating data to another node. + ElasticsearchMigratingDataPhase ElasticsearchOrchestrationPhase = "MigratingData" + // ElasticsearchResourceInvalid is marking a resource as invalid, should never happen if admission control is installed correctly. + ElasticsearchResourceInvalid ElasticsearchOrchestrationPhase = "Invalid" +) + +// ElasticsearchStatus defines the observed state of Elasticsearch +type ElasticsearchStatus struct { + commonv1beta1.ReconcilerStatus `json:",inline"` + Health ElasticsearchHealth `json:"health,omitempty"` + Phase ElasticsearchOrchestrationPhase `json:"phase,omitempty"` +} + +type ZenDiscoveryStatus struct { + MinimumMasterNodes int `json:"minimumMasterNodes,omitempty"` +} + +// IsDegraded returns true if the current status is worse than the previous. +func (es ElasticsearchStatus) IsDegraded(prev ElasticsearchStatus) bool { + return es.Health.Less(prev.Health) +} + +// +kubebuilder:object:root=true + +// Elasticsearch is the Schema for the elasticsearches API +// +kubebuilder:resource:categories=elastic,shortName=es +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" +// +kubebuilder:printcolumn:name="nodes",type="integer",JSONPath=".status.availableNodes",description="Available nodes" +// +kubebuilder:printcolumn:name="version",type="string",JSONPath=".spec.version",description="Elasticsearch version" +// +kubebuilder:printcolumn:name="phase",type="string",JSONPath=".status.phase" +// +kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:storageversion +type Elasticsearch struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ElasticsearchSpec `json:"spec,omitempty"` + Status ElasticsearchStatus `json:"status,omitempty"` +} + +// IsMarkedForDeletion returns true if the Elasticsearch is going to be deleted +func (e Elasticsearch) IsMarkedForDeletion() bool { + return !e.DeletionTimestamp.IsZero() +} + +func (e Elasticsearch) SecureSettings() []commonv1beta1.SecretSource { + return e.Spec.SecureSettings +} + +// Kind can technically be retrieved from metav1.Object, but there is a bug preventing us to retrieve it +// see https://github.com/kubernetes-sigs/controller-runtime/issues/406 +func (e Elasticsearch) Kind() string { + return Kind +} + +// +kubebuilder:object:root=true + +// ElasticsearchList contains a list of Elasticsearch clusters +type ElasticsearchList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Elasticsearch `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Elasticsearch{}, &ElasticsearchList{}) +} diff --git a/pkg/apis/elasticsearch/v1beta1/elasticsearch_types_test.go b/pkg/apis/elasticsearch/v1beta1/elasticsearch_types_test.go new file mode 100644 index 0000000000..a0ede51653 --- /dev/null +++ b/pkg/apis/elasticsearch/v1beta1/elasticsearch_types_test.go @@ -0,0 +1,126 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + "fmt" + "sort" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestElasticsearchHealth_Less(t *testing.T) { + + tests := []struct { + inputs []ElasticsearchHealth + sorted bool + }{ + { + inputs: []ElasticsearchHealth{ + "", + ElasticsearchYellowHealth, + "", + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchUnknownHealth, + ElasticsearchYellowHealth, + ElasticsearchUnknownHealth, + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchRedHealth, + ElasticsearchYellowHealth, + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchRedHealth, + ElasticsearchRedHealth, + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchRedHealth, + ElasticsearchGreenHealth, + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchRedHealth, + ElasticsearchYellowHealth, + ElasticsearchGreenHealth, + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchYellowHealth, + ElasticsearchGreenHealth, + }, + sorted: true, + }, + { + inputs: []ElasticsearchHealth{ + ElasticsearchGreenHealth, + ElasticsearchYellowHealth, + }, + sorted: false, + }, + } + + for _, tt := range tests { + assert.Equal(t, sort.SliceIsSorted(tt.inputs, func(i, j int) bool { + return tt.inputs[i].Less(tt.inputs[j]) + }), tt.sorted, fmt.Sprintf("%v", tt.inputs)) + } +} + +func TestElasticsearchCluster_IsMarkedForDeletion(t *testing.T) { + zeroTime := metav1.NewTime(time.Time{}) + currentTime := metav1.NewTime(time.Now()) + tests := []struct { + name string + deletionTimestamp *metav1.Time + want bool + }{ + { + name: "deletion timestamp nil", + deletionTimestamp: nil, + want: false, + }, + { + name: "deletion timestamp set to its zero value", + deletionTimestamp: &zeroTime, + want: false, + }, + { + name: "deletion timestamp set to any non-zero value", + deletionTimestamp: ¤tTime, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + e := Elasticsearch{ + ObjectMeta: metav1.ObjectMeta{ + DeletionTimestamp: tt.deletionTimestamp, + }, + } + require.Equal(t, tt.want, e.IsMarkedForDeletion()) + }) + } +} diff --git a/pkg/apis/elasticsearch/v1beta1/groupversion_info.go b/pkg/apis/elasticsearch/v1beta1/groupversion_info.go new file mode 100644 index 0000000000..b63054333c --- /dev/null +++ b/pkg/apis/elasticsearch/v1beta1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1 contains API Schema definitions for the batch v1 API group +// +kubebuilder:object:generate=true +// +groupName=elasticsearch.k8s.elastic.co +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "elasticsearch.k8s.elastic.co", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/elasticsearch/v1beta1/zz_generated.deepcopy.go b/pkg/apis/elasticsearch/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..53a7ed6cc8 --- /dev/null +++ b/pkg/apis/elasticsearch/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,260 @@ +// +build !ignore_autogenerated + +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChangeBudget) DeepCopyInto(out *ChangeBudget) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChangeBudget. +func (in *ChangeBudget) DeepCopy() *ChangeBudget { + if in == nil { + return nil + } + out := new(ChangeBudget) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSettings) DeepCopyInto(out *ClusterSettings) { + *out = *in + if in.InitialMasterNodes != nil { + in, out := &in.InitialMasterNodes, &out.InitialMasterNodes + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSettings. +func (in *ClusterSettings) DeepCopy() *ClusterSettings { + if in == nil { + return nil + } + out := new(ClusterSettings) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Elasticsearch) DeepCopyInto(out *Elasticsearch) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Elasticsearch. +func (in *Elasticsearch) DeepCopy() *Elasticsearch { + if in == nil { + return nil + } + out := new(Elasticsearch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Elasticsearch) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ElasticsearchList) DeepCopyInto(out *ElasticsearchList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Elasticsearch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchList. +func (in *ElasticsearchList) DeepCopy() *ElasticsearchList { + if in == nil { + return nil + } + out := new(ElasticsearchList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ElasticsearchList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ElasticsearchSettings) DeepCopyInto(out *ElasticsearchSettings) { + *out = *in + out.Node = in.Node + in.Cluster.DeepCopyInto(&out.Cluster) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchSettings. +func (in *ElasticsearchSettings) DeepCopy() *ElasticsearchSettings { + if in == nil { + return nil + } + out := new(ElasticsearchSettings) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ElasticsearchSpec) DeepCopyInto(out *ElasticsearchSpec) { + *out = *in + if in.SetVMMaxMapCount != nil { + in, out := &in.SetVMMaxMapCount, &out.SetVMMaxMapCount + *out = new(bool) + **out = **in + } + in.HTTP.DeepCopyInto(&out.HTTP) + if in.Nodes != nil { + in, out := &in.Nodes, &out.Nodes + *out = make([]NodeSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.UpdateStrategy.DeepCopyInto(&out.UpdateStrategy) + if in.PodDisruptionBudget != nil { + in, out := &in.PodDisruptionBudget, &out.PodDisruptionBudget + *out = new(commonv1beta1.PodDisruptionBudgetTemplate) + (*in).DeepCopyInto(*out) + } + if in.SecureSettings != nil { + in, out := &in.SecureSettings, &out.SecureSettings + *out = make([]commonv1beta1.SecretSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchSpec. +func (in *ElasticsearchSpec) DeepCopy() *ElasticsearchSpec { + if in == nil { + return nil + } + out := new(ElasticsearchSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ElasticsearchStatus) DeepCopyInto(out *ElasticsearchStatus) { + *out = *in + out.ReconcilerStatus = in.ReconcilerStatus +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchStatus. +func (in *ElasticsearchStatus) DeepCopy() *ElasticsearchStatus { + if in == nil { + return nil + } + out := new(ElasticsearchStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Node) DeepCopyInto(out *Node) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node. +func (in *Node) DeepCopy() *Node { + if in == nil { + return nil + } + out := new(Node) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSpec) DeepCopyInto(out *NodeSpec) { + *out = *in + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = (*in).DeepCopy() + } + in.PodTemplate.DeepCopyInto(&out.PodTemplate) + if in.VolumeClaimTemplates != nil { + in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates + *out = make([]v1.PersistentVolumeClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSpec. +func (in *NodeSpec) DeepCopy() *NodeSpec { + if in == nil { + return nil + } + out := new(NodeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpdateStrategy) DeepCopyInto(out *UpdateStrategy) { + *out = *in + if in.ChangeBudget != nil { + in, out := &in.ChangeBudget, &out.ChangeBudget + *out = new(ChangeBudget) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateStrategy. +func (in *UpdateStrategy) DeepCopy() *UpdateStrategy { + if in == nil { + return nil + } + out := new(UpdateStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ZenDiscoveryStatus) DeepCopyInto(out *ZenDiscoveryStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZenDiscoveryStatus. +func (in *ZenDiscoveryStatus) DeepCopy() *ZenDiscoveryStatus { + if in == nil { + return nil + } + out := new(ZenDiscoveryStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/kibana/v1alpha1/kibana_types.go b/pkg/apis/kibana/v1alpha1/kibana_types.go index 2d17cf0718..f87d38e55e 100644 --- a/pkg/apis/kibana/v1alpha1/kibana_types.go +++ b/pkg/apis/kibana/v1alpha1/kibana_types.go @@ -65,9 +65,9 @@ const ( // KibanaStatus defines the observed state of Kibana type KibanaStatus struct { - commonv1alpha1.ReconcilerStatus - Health KibanaHealth `json:"health,omitempty"` - AssociationStatus commonv1alpha1.AssociationStatus `json:"associationStatus,omitempty"` + commonv1alpha1.ReconcilerStatus `json:",inline"` + Health KibanaHealth `json:"health,omitempty"` + AssociationStatus commonv1alpha1.AssociationStatus `json:"associationStatus,omitempty"` } // IsDegraded returns true if the current status is worse than the previous. @@ -102,12 +102,10 @@ func (k *Kibana) SetAssociationConf(assocConf *commonv1alpha1.AssociationConf) { k.assocConf = assocConf } -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true // Kibana is the Schema for the kibanas API -// +kubebuilder:categories=elastic -// +kubebuilder:resource:shortName=kb +// +kubebuilder:resource:categories=elastic,shortName=kb // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" // +kubebuilder:printcolumn:name="nodes",type="integer",JSONPath=".status.availableNodes",description="Available nodes" @@ -117,9 +115,9 @@ type Kibana struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec KibanaSpec `json:"spec,omitempty"` - Status KibanaStatus `json:"status,omitempty"` - assocConf *commonv1alpha1.AssociationConf + Spec KibanaSpec `json:"spec,omitempty"` + Status KibanaStatus `json:"status,omitempty"` + assocConf *commonv1alpha1.AssociationConf `json:"-"` //nolint:govet } // +kubebuilder:object:root=true diff --git a/pkg/apis/kibana/v1beta1/groupversion_info.go b/pkg/apis/kibana/v1beta1/groupversion_info.go new file mode 100644 index 0000000000..a52e94450d --- /dev/null +++ b/pkg/apis/kibana/v1beta1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1beta1 contains API Schema definitions for the apm v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=kibana.k8s.elastic.co +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "kibana.k8s.elastic.co", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/kibana/v1beta1/kibana_types.go b/pkg/apis/kibana/v1beta1/kibana_types.go new file mode 100644 index 0000000000..21caea1628 --- /dev/null +++ b/pkg/apis/kibana/v1beta1/kibana_types.go @@ -0,0 +1,135 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" +) + +const ( + KibanaContainerName = "kibana" + Kind = "Kibana" +) + +// KibanaSpec defines the desired state of Kibana +type KibanaSpec struct { + // Version represents the version of Kibana + Version string `json:"version,omitempty"` + + // Image represents the docker image that will be used. + Image string `json:"image,omitempty"` + + // NodeCount defines how many nodes the Kibana deployment must have. + NodeCount int32 `json:"nodeCount,omitempty"` + + // ElasticsearchRef references an Elasticsearch resource in the Kubernetes cluster. + // If the namespace is not specified, the current resource namespace will be used. + ElasticsearchRef commonv1beta1.ObjectSelector `json:"elasticsearchRef,omitempty"` + + // Config represents Kibana configuration. + Config *commonv1beta1.Config `json:"config,omitempty"` + + // HTTP contains settings for HTTP. + HTTP commonv1beta1.HTTPConfig `json:"http,omitempty"` + + // PodTemplate can be used to propagate configuration to Kibana pods. + // This allows specifying custom annotations, labels, environment variables, + // affinity, resources, etc. for the pods created from this NodeSpec. + // +kubebuilder:validation:Optional + PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"` + + // SecureSettings references secrets containing secure settings, to be injected + // into Kibana keystore on each node. + // Each individual key/value entry in the referenced secrets is considered as an + // individual secure setting to be injected. + // You can use the `entries` and `key` fields to consider only a subset of the secret + // entries and the `path` field to change the target path of a secret entry key. + // The secret must exist in the same namespace as the Kibana resource. + SecureSettings []commonv1beta1.SecretSource `json:"secureSettings,omitempty"` +} + +// KibanaHealth expresses the status of the Kibana instances. +type KibanaHealth string + +const ( + // KibanaRed means no instance is currently available. + KibanaRed KibanaHealth = "red" + // KibanaGreen means at least one instance is available. + KibanaGreen KibanaHealth = "green" +) + +// KibanaStatus defines the observed state of Kibana +type KibanaStatus struct { + commonv1beta1.ReconcilerStatus `json:",inline"` + Health KibanaHealth `json:"health,omitempty"` + AssociationStatus commonv1beta1.AssociationStatus `json:"associationStatus,omitempty"` +} + +// IsDegraded returns true if the current status is worse than the previous. +func (ks KibanaStatus) IsDegraded(prev KibanaStatus) bool { + return prev.Health == KibanaGreen && ks.Health != KibanaGreen +} + +// IsMarkedForDeletion returns true if the Kibana is going to be deleted +func (k Kibana) IsMarkedForDeletion() bool { + return !k.DeletionTimestamp.IsZero() +} + +func (k *Kibana) ElasticsearchRef() commonv1beta1.ObjectSelector { + return k.Spec.ElasticsearchRef +} + +func (k *Kibana) SecureSettings() []commonv1beta1.SecretSource { + return k.Spec.SecureSettings +} + +// Kind can technically be retrieved from metav1.Object, but there is a bug preventing us to retrieve it +// see https://github.com/kubernetes-sigs/controller-runtime/issues/406 +func (k *Kibana) Kind() string { + return Kind +} + +func (k *Kibana) AssociationConf() *commonv1beta1.AssociationConf { + return k.assocConf +} + +func (k *Kibana) SetAssociationConf(assocConf *commonv1beta1.AssociationConf) { + k.assocConf = assocConf +} + +// +kubebuilder:object:root=true + +// Kibana is the Schema for the kibanas API +// +kubebuilder:resource:categories=elastic,shortName=kb +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" +// +kubebuilder:printcolumn:name="nodes",type="integer",JSONPath=".status.availableNodes",description="Available nodes" +// +kubebuilder:printcolumn:name="version",type="string",JSONPath=".spec.version",description="Kibana version" +// +kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:storageversion +type Kibana struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KibanaSpec `json:"spec,omitempty"` + Status KibanaStatus `json:"status,omitempty"` + assocConf *commonv1beta1.AssociationConf `json:"-"` //nolint:govet +} + +// +kubebuilder:object:root=true + +// KibanaList contains a list of Kibana +type KibanaList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Kibana `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Kibana{}, &KibanaList{}) +} diff --git a/pkg/apis/kibana/v1beta1/zz_generated.deepcopy.go b/pkg/apis/kibana/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..e1e4ac3583 --- /dev/null +++ b/pkg/apis/kibana/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,123 @@ +// +build !ignore_autogenerated + +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Kibana) DeepCopyInto(out *Kibana) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + if in.assocConf != nil { + in, out := &in.assocConf, &out.assocConf + *out = new(commonv1beta1.AssociationConf) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Kibana. +func (in *Kibana) DeepCopy() *Kibana { + if in == nil { + return nil + } + out := new(Kibana) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Kibana) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KibanaList) DeepCopyInto(out *KibanaList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Kibana, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KibanaList. +func (in *KibanaList) DeepCopy() *KibanaList { + if in == nil { + return nil + } + out := new(KibanaList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KibanaList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KibanaSpec) DeepCopyInto(out *KibanaSpec) { + *out = *in + out.ElasticsearchRef = in.ElasticsearchRef + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = (*in).DeepCopy() + } + in.HTTP.DeepCopyInto(&out.HTTP) + in.PodTemplate.DeepCopyInto(&out.PodTemplate) + if in.SecureSettings != nil { + in, out := &in.SecureSettings, &out.SecureSettings + *out = make([]commonv1beta1.SecretSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KibanaSpec. +func (in *KibanaSpec) DeepCopy() *KibanaSpec { + if in == nil { + return nil + } + out := new(KibanaSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KibanaStatus) DeepCopyInto(out *KibanaStatus) { + *out = *in + out.ReconcilerStatus = in.ReconcilerStatus +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KibanaStatus. +func (in *KibanaStatus) DeepCopy() *KibanaStatus { + if in == nil { + return nil + } + out := new(KibanaStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/controller/apmserver/apmserver_controller.go b/pkg/controller/apmserver/apmserver_controller.go index a3024f93bb..797fd0bf84 100644 --- a/pkg/controller/apmserver/apmserver_controller.go +++ b/pkg/controller/apmserver/apmserver_controller.go @@ -11,7 +11,7 @@ import ( "reflect" "sync/atomic" - apmv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + apmv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" apmcerts "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/config" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" @@ -98,7 +98,7 @@ func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileAp func addWatches(c controller.Controller, r *ReconcileApmServer) error { // Watch for changes to ApmServer - err := c.Watch(&source.Kind{Type: &apmv1alpha1.ApmServer{}}, &handler.EnqueueRequestForObject{}) + err := c.Watch(&source.Kind{Type: &apmv1beta1.ApmServer{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -106,7 +106,7 @@ func addWatches(c controller.Controller, r *ReconcileApmServer) error { // Watch Deployments if err := c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &apmv1alpha1.ApmServer{}, + OwnerType: &apmv1beta1.ApmServer{}, }); err != nil { return err } @@ -114,7 +114,7 @@ func addWatches(c controller.Controller, r *ReconcileApmServer) error { // Watch services if err := c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &apmv1alpha1.ApmServer{}, + OwnerType: &apmv1beta1.ApmServer{}, }); err != nil { return err } @@ -122,7 +122,7 @@ func addWatches(c controller.Controller, r *ReconcileApmServer) error { // Watch secrets if err := c.Watch(&source.Kind{Type: &corev1.Secret{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &apmv1alpha1.ApmServer{}, + OwnerType: &apmv1beta1.ApmServer{}, }); err != nil { return err } @@ -178,7 +178,7 @@ var _ driver.Interface = &ReconcileApmServer{} func (r *ReconcileApmServer) Reconcile(request reconcile.Request) (reconcile.Result, error) { defer common.LogReconciliationRun(log, request, &r.iteration)() - var as apmv1alpha1.ApmServer + var as apmv1beta1.ApmServer if ok, err := association.FetchWithAssociation(r.Client, request, &as); !ok { return reconcile.Result{}, err } @@ -212,7 +212,7 @@ func (r *ReconcileApmServer) Reconcile(request reconcile.Request) (reconcile.Res return r.doReconcile(request, &as) } -func (r *ReconcileApmServer) isCompatible(as *apmv1alpha1.ApmServer) (bool, error) { +func (r *ReconcileApmServer) isCompatible(as *apmv1beta1.ApmServer) (bool, error) { selector := map[string]string{labels.ApmServerNameLabelName: as.Name} compat, err := annotation.ReconcileCompatibility(r.Client, as, selector, r.OperatorInfo.BuildInfo.Version) if err != nil { @@ -221,7 +221,7 @@ func (r *ReconcileApmServer) isCompatible(as *apmv1alpha1.ApmServer) (bool, erro return compat, err } -func (r *ReconcileApmServer) doReconcile(request reconcile.Request, as *apmv1alpha1.ApmServer) (reconcile.Result, error) { +func (r *ReconcileApmServer) doReconcile(request reconcile.Request, as *apmv1beta1.ApmServer) (reconcile.Result, error) { state := NewState(request, as) svc, err := common.ReconcileService(r.Client, r.scheme, NewService(*as), as) if err != nil { @@ -249,7 +249,7 @@ func (r *ReconcileApmServer) doReconcile(request reconcile.Request, as *apmv1alp return r.updateStatus(state) } -func (r *ReconcileApmServer) reconcileApmServerSecret(as *apmv1alpha1.ApmServer) (*corev1.Secret, error) { +func (r *ReconcileApmServer) reconcileApmServerSecret(as *apmv1beta1.ApmServer) (*corev1.Secret, error) { expectedApmServerSecret := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Namespace: as.Namespace, @@ -306,7 +306,7 @@ func (r *ReconcileApmServer) reconcileApmServerSecret(as *apmv1alpha1.ApmServer) } func (r *ReconcileApmServer) deploymentParams( - as *apmv1alpha1.ApmServer, + as *apmv1beta1.ApmServer, params PodSpecParams, ) (deployment.Params, error) { @@ -373,7 +373,7 @@ func (r *ReconcileApmServer) deploymentParams( } httpCertsVolume := http.HTTPCertSecretVolume(apmname.APMNamer, as.Name) podSpec.Spec.Volumes = append(podSpec.Spec.Volumes, httpCertsVolume.Volume()) - apmServerContainer := pod.ContainerByName(podSpec.Spec, apmv1alpha1.APMServerContainerName) + apmServerContainer := pod.ContainerByName(podSpec.Spec, apmv1beta1.APMServerContainerName) apmServerContainer.VolumeMounts = append(apmServerContainer.VolumeMounts, httpCertsVolume.VolumeMount()) } @@ -394,7 +394,7 @@ func (r *ReconcileApmServer) deploymentParams( func (r *ReconcileApmServer) reconcileApmServerDeployment( state State, - as *apmv1alpha1.ApmServer, + as *apmv1beta1.ApmServer, ) (State, error) { reconciledApmServerSecret, err := r.reconcileApmServerSecret(as) if err != nil { @@ -460,7 +460,7 @@ func (r *ReconcileApmServer) updateStatus(state State) (reconcile.Result, error) } // finalizersFor returns the list of finalizers applying to a given APM deployment -func (r *ReconcileApmServer) finalizersFor(as apmv1alpha1.ApmServer) []finalizer.Finalizer { +func (r *ReconcileApmServer) finalizersFor(as apmv1beta1.ApmServer) []finalizer.Finalizer { return []finalizer.Finalizer{ keystore.Finalizer(k8s.ExtractNamespacedName(&as), r.dynamicWatches, as.Kind()), } diff --git a/pkg/controller/apmserver/apmserver_controller_test.go b/pkg/controller/apmserver/apmserver_controller_test.go index 2b772bbcb9..84d8036cc1 100644 --- a/pkg/controller/apmserver/apmserver_controller_test.go +++ b/pkg/controller/apmserver/apmserver_controller_test.go @@ -7,7 +7,7 @@ package apmserver import ( "testing" - apmv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + apmv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" @@ -140,7 +140,7 @@ func expectedDeploymentParams() testParams { MountPath: "/mnt/elastic-internal/http-certs", }, }, - Name: apmv1alpha1.APMServerContainerName, + Name: apmv1beta1.APMServerContainerName, Image: "docker.elastic.co/apm/apm-server:1.0", Command: []string{ "apm-server", @@ -189,11 +189,11 @@ func expectedDeploymentParams() testParams { func TestReconcileApmServer_deploymentParams(t *testing.T) { s := scheme.Scheme - if err := apmv1alpha1.SchemeBuilder.AddToScheme(s); err != nil { + if err := apmv1beta1.SchemeBuilder.AddToScheme(s); err != nil { t.Error(err) } - apmFixture := &apmv1alpha1.ApmServer{ + apmFixture := &apmv1beta1.ApmServer{ ObjectMeta: v1.ObjectMeta{ Name: "test-apm-server", }, @@ -217,7 +217,7 @@ func TestReconcileApmServer_deploymentParams(t *testing.T) { } type args struct { - as *apmv1alpha1.ApmServer + as *apmv1beta1.ApmServer podSpecParams PodSpecParams initialObjects []runtime.Object } diff --git a/pkg/controller/apmserver/certificates/reconcile.go b/pkg/controller/apmserver/certificates/reconcile.go index 96713e625c..60fe314ba4 100644 --- a/pkg/controller/apmserver/certificates/reconcile.go +++ b/pkg/controller/apmserver/certificates/reconcile.go @@ -7,7 +7,7 @@ package certificates import ( "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/name" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" @@ -20,7 +20,7 @@ import ( func Reconcile( driver driver.Interface, - apm *v1alpha1.ApmServer, + apm *v1beta1.ApmServer, services []coverv1.Service, rotation certificates.RotationParams, ) reconciler.Results { diff --git a/pkg/controller/apmserver/config/config.go b/pkg/controller/apmserver/config/config.go index db12e921a9..dcae290b69 100644 --- a/pkg/controller/apmserver/config/config.go +++ b/pkg/controller/apmserver/config/config.go @@ -9,8 +9,8 @@ import ( "path" "path/filepath" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/association" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" @@ -33,10 +33,10 @@ const ( APMServerSSLCertificate = "apm-server.ssl.certificate" ) -func NewConfigFromSpec(c k8s.Client, as *v1alpha1.ApmServer) (*settings.CanonicalConfig, error) { +func NewConfigFromSpec(c k8s.Client, as *v1beta1.ApmServer) (*settings.CanonicalConfig, error) { specConfig := as.Spec.Config if specConfig == nil { - specConfig = &commonv1alpha1.Config{} + specConfig = &commonv1beta1.Config{} } userSettings, err := settings.NewCanonicalConfigFrom(specConfig.Data) @@ -84,7 +84,7 @@ func NewConfigFromSpec(c k8s.Client, as *v1alpha1.ApmServer) (*settings.Canonica return cfg, nil } -func tlsSettings(as *v1alpha1.ApmServer) map[string]interface{} { +func tlsSettings(as *v1beta1.ApmServer) map[string]interface{} { if !as.Spec.HTTP.TLS.Enabled() { return nil } diff --git a/pkg/controller/apmserver/config/config_test.go b/pkg/controller/apmserver/config/config_test.go index 6751672f56..184ac6c705 100644 --- a/pkg/controller/apmserver/config/config_test.go +++ b/pkg/controller/apmserver/config/config_test.go @@ -7,8 +7,8 @@ package config import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/require" @@ -21,7 +21,7 @@ func TestNewConfigFromSpec(t *testing.T) { testCases := []struct { name string configOverrides map[string]interface{} - assocConf *commonv1alpha1.AssociationConf + assocConf *commonv1beta1.AssociationConf wantConf map[string]interface{} wantErr bool }{ @@ -39,7 +39,7 @@ func TestNewConfigFromSpec(t *testing.T) { }, { name: "without Elasticsearch CA cert", - assocConf: &commonv1alpha1.AssociationConf{ + assocConf: &commonv1beta1.AssociationConf{ AuthSecretName: "test-es-elastic-user", AuthSecretKey: "elastic", CASecretName: "test-es-http-ca-public", @@ -54,7 +54,7 @@ func TestNewConfigFromSpec(t *testing.T) { }, { name: "with Elasticsearch CA cert", - assocConf: &commonv1alpha1.AssociationConf{ + assocConf: &commonv1beta1.AssociationConf{ AuthSecretName: "test-es-elastic-user", AuthSecretKey: "elastic", CASecretName: "test-es-http-ca-public", @@ -70,7 +70,7 @@ func TestNewConfigFromSpec(t *testing.T) { }, { name: "missing auth secret", - assocConf: &commonv1alpha1.AssociationConf{ + assocConf: &commonv1beta1.AssociationConf{ AuthSecretName: "wrong-secret", AuthSecretKey: "elastic", CASecretName: "test-es-http-ca-public", @@ -100,13 +100,13 @@ func TestNewConfigFromSpec(t *testing.T) { } } -func mkAPMServer(config map[string]interface{}, assocConf *commonv1alpha1.AssociationConf) *v1alpha1.ApmServer { - apmServer := &v1alpha1.ApmServer{ +func mkAPMServer(config map[string]interface{}, assocConf *commonv1beta1.AssociationConf) *v1beta1.ApmServer { + apmServer := &v1beta1.ApmServer{ ObjectMeta: metav1.ObjectMeta{ Name: "apm-server", }, - Spec: v1alpha1.ApmServerSpec{ - Config: &commonv1alpha1.Config{Data: config}, + Spec: v1beta1.ApmServerSpec{ + Config: &commonv1beta1.Config{Data: config}, }, } diff --git a/pkg/controller/apmserver/config/reconcile.go b/pkg/controller/apmserver/config/reconcile.go index 85bd6c11d0..8b0cd96e44 100644 --- a/pkg/controller/apmserver/config/reconcile.go +++ b/pkg/controller/apmserver/config/reconcile.go @@ -7,7 +7,7 @@ package config import ( "reflect" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/name" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" @@ -24,7 +24,7 @@ var log = logf.Log.WithName("apmserver-config") // Reconcile reconciles the configuration of the APM server: it first creates the configuration from the APM // specification and then reconcile the underlying secret. -func Reconcile(client k8s.Client, scheme *runtime.Scheme, as *v1alpha1.ApmServer) (*corev1.Secret, error) { +func Reconcile(client k8s.Client, scheme *runtime.Scheme, as *v1beta1.ApmServer) (*corev1.Secret, error) { // Create a new configuration from the APM object spec. cfg, err := NewConfigFromSpec(client, as) diff --git a/pkg/controller/apmserver/pod.go b/pkg/controller/apmserver/pod.go index d3cf6e79c2..ddf11b7092 100644 --- a/pkg/controller/apmserver/pod.go +++ b/pkg/controller/apmserver/pod.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/config" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" @@ -90,7 +90,7 @@ func imageWithVersion(image string, version string) string { return stringsutil.Concat(image, ":", version) } -func newPodSpec(as *v1alpha1.ApmServer, p PodSpecParams) corev1.PodTemplateSpec { +func newPodSpec(as *v1beta1.ApmServer, p PodSpecParams) corev1.PodTemplateSpec { configSecretVolume := volume.NewSecretVolumeWithMountPath( p.ConfigSecret.Name, "config", @@ -108,7 +108,7 @@ func newPodSpec(as *v1alpha1.ApmServer, p PodSpecParams) corev1.PodTemplateSpec }) builder := defaults.NewPodTemplateBuilder( - p.PodTemplate, v1alpha1.APMServerContainerName). + p.PodTemplate, v1beta1.APMServerContainerName). WithResources(DefaultResources). WithDockerImage(p.CustomImageName, imageWithVersion(defaultImageRepositoryAndName, p.Version)). WithReadinessProbe(readinessProbe(as.Spec.HTTP.TLS.Enabled())). diff --git a/pkg/controller/apmserver/pod_test.go b/pkg/controller/apmserver/pod_test.go index 029550d886..57ead41f69 100644 --- a/pkg/controller/apmserver/pod_test.go +++ b/pkg/controller/apmserver/pod_test.go @@ -11,7 +11,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/volume" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/settings" ) @@ -26,13 +26,13 @@ func TestNewPodSpec(t *testing.T) { probe := readinessProbe(true) tests := []struct { name string - as v1alpha1.ApmServer + as v1beta1.ApmServer p PodSpecParams want corev1.PodTemplateSpec }{ { name: "create default pod spec", - as: v1alpha1.ApmServer{ + as: v1beta1.ApmServer{ TypeMeta: metav1.TypeMeta{ Kind: "ApmServer", }, @@ -63,7 +63,7 @@ func TestNewPodSpec(t *testing.T) { AutomountServiceAccountToken: &varFalse, Containers: []corev1.Container{ { - Name: v1alpha1.APMServerContainerName, + Name: v1beta1.APMServerContainerName, Image: imageWithVersion(defaultImageRepositoryAndName, "7.0.1"), Env: []corev1.EnvVar{ { diff --git a/pkg/controller/apmserver/services.go b/pkg/controller/apmserver/services.go index 60843bbde3..5944aefbbc 100644 --- a/pkg/controller/apmserver/services.go +++ b/pkg/controller/apmserver/services.go @@ -5,14 +5,14 @@ package apmserver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" apmname "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/name" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" corev1 "k8s.io/api/core/v1" ) -func NewService(as v1alpha1.ApmServer) *corev1.Service { +func NewService(as v1beta1.ApmServer) *corev1.Service { svc := corev1.Service{ ObjectMeta: as.Spec.HTTP.Service.ObjectMeta, Spec: as.Spec.HTTP.Service.Spec, diff --git a/pkg/controller/apmserver/state.go b/pkg/controller/apmserver/state.go index 6744ecd33b..d69e85dc09 100644 --- a/pkg/controller/apmserver/state.go +++ b/pkg/controller/apmserver/state.go @@ -5,7 +5,7 @@ package apmserver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -14,16 +14,16 @@ import ( // State holds the accumulated state during the reconcile loop including the response and a pointer to an ApmServer // resource for status updates. type State struct { - ApmServer *v1alpha1.ApmServer + ApmServer *v1beta1.ApmServer Result reconcile.Result Request reconcile.Request - originalApmServer *v1alpha1.ApmServer + originalApmServer *v1beta1.ApmServer } // NewState creates a new reconcile state based on the given request and ApmServer resource with the resource // state reset to empty. -func NewState(request reconcile.Request, as *v1alpha1.ApmServer) State { +func NewState(request reconcile.Request, as *v1beta1.ApmServer) State { return State{Request: request, ApmServer: as, originalApmServer: as.DeepCopy()} } @@ -31,10 +31,10 @@ func NewState(request reconcile.Request, as *v1alpha1.ApmServer) State { func (s State) UpdateApmServerState(deployment v1.Deployment, apmServerSecret corev1.Secret) { s.ApmServer.Status.SecretTokenSecretName = apmServerSecret.Name s.ApmServer.Status.AvailableNodes = int(deployment.Status.AvailableReplicas) // TODO lossy type conversion - s.ApmServer.Status.Health = v1alpha1.ApmServerRed + s.ApmServer.Status.Health = v1beta1.ApmServerRed for _, c := range deployment.Status.Conditions { if c.Type == v1.DeploymentAvailable && c.Status == corev1.ConditionTrue { - s.ApmServer.Status.Health = v1alpha1.ApmServerGreen + s.ApmServer.Status.Health = v1beta1.ApmServerGreen } } } diff --git a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go index 7b9d0bd330..c37070df36 100644 --- a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go +++ b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go @@ -8,9 +8,9 @@ import ( "reflect" "time" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" @@ -204,9 +204,9 @@ func watchFinalizer(assocKey types.NamespacedName, w watches.DynamicWatches) fin } } -func resultFromStatus(status commonv1alpha1.AssociationStatus) reconcile.Result { +func resultFromStatus(status commonv1beta1.AssociationStatus) reconcile.Result { switch status { - case commonv1alpha1.AssociationPending: + case commonv1beta1.AssociationPending: return defaultRequeue // retry default: return reconcile.Result{} // we are done or there is not much we can do @@ -222,11 +222,11 @@ func (r *ReconcileApmServerElasticsearchAssociation) isCompatible(apmServer *apm return compat, err } -func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer *apmtype.ApmServer) (commonv1alpha1.AssociationStatus, error) { +func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer *apmtype.ApmServer) (commonv1beta1.AssociationStatus, error) { // no auto-association nothing to do elasticsearchRef := apmServer.Spec.ElasticsearchRef if !elasticsearchRef.IsDefined() { - return commonv1alpha1.AssociationUnknown, nil + return commonv1beta1.AssociationUnknown, nil } if elasticsearchRef.Namespace == "" { // no namespace provided: default to the APM server namespace @@ -242,7 +242,7 @@ func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer Watcher: assocKey, }) if err != nil { - return commonv1alpha1.AssociationFailed, err + return commonv1beta1.AssociationFailed, err } var es estype.Elasticsearch @@ -254,12 +254,12 @@ func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer // ES is not found, remove any existing backend configuration and retry in a bit. if err := association.RemoveAssociationConf(r.Client, apmServer); err != nil && !errors.IsConflict(err) { log.Error(err, "Failed to remove Elasticsearch output from APMServer object", "namespace", apmServer.Namespace, "name", apmServer.Name) - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } - return commonv1alpha1.AssociationPending, nil + return commonv1beta1.AssociationPending, nil } - return commonv1alpha1.AssociationFailed, err + return commonv1beta1.AssociationFailed, err } if err := association.ReconcileEsUser( @@ -274,17 +274,17 @@ func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer apmUserSuffix, es, ); err != nil { // TODO distinguish conflicts and non-recoverable errors here - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } caSecret, err := r.reconcileElasticsearchCA(apmServer, elasticsearchRef.NamespacedName()) if err != nil { - return commonv1alpha1.AssociationPending, err // maybe not created yet + return commonv1beta1.AssociationPending, err // maybe not created yet } // construct the expected ES output configuration authSecretRef := association.ClearTextSecretKeySelector(apmServer, apmUserSuffix) - expectedAssocConf := &commonv1alpha1.AssociationConf{ + expectedAssocConf := &commonv1beta1.AssociationConf{ AuthSecretName: authSecretRef.Name, AuthSecretKey: authSecretRef.Key, CACertProvided: caSecret.CACertProvided, @@ -296,10 +296,10 @@ func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer log.Info("Updating APMServer spec with Elasticsearch association configuration", "namespace", apmServer.Namespace, "name", apmServer.Name) if err := association.UpdateAssociationConf(r.Client, apmServer, expectedAssocConf); err != nil { if errors.IsConflict(err) { - return commonv1alpha1.AssociationPending, nil + return commonv1beta1.AssociationPending, nil } log.Error(err, "Failed to update APMServer association configuration", "namespace", apmServer.Namespace, "name", apmServer.Name) - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } apmServer.SetAssociationConf(expectedAssocConf) } @@ -308,7 +308,7 @@ func (r *ReconcileApmServerElasticsearchAssociation) reconcileInternal(apmServer log.Error(err, "Error while trying to delete orphaned resources. Continuing.", "namespace", apmServer.Namespace, "as_name", apmServer.Name) } - return commonv1alpha1.AssociationEstablished, nil + return commonv1beta1.AssociationEstablished, nil } func (r *ReconcileApmServerElasticsearchAssociation) reconcileElasticsearchCA(apm *apmtype.ApmServer, es types.NamespacedName) (association.CASecret, error) { diff --git a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go index 3cf906dce9..599055fc74 100644 --- a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go +++ b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go @@ -7,9 +7,9 @@ package apmserverelasticsearchassociation import ( "testing" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -28,7 +28,7 @@ const ( var t = true var ownerRefFixture = metav1.OwnerReference{ - APIVersion: "apmserver.k8s.elastic.co/v1alpha1", + APIVersion: "apmserver.k8s.elastic.co/v1beta1", Kind: "ApmServer", Name: "as", UID: "", @@ -43,7 +43,7 @@ var apmFixture = apmtype.ApmServer{ Namespace: "default", }, Spec: apmtype.ApmServerSpec{ - ElasticsearchRef: commonv1alpha1.ObjectSelector{ + ElasticsearchRef: commonv1beta1.ObjectSelector{ Name: "es", Namespace: "default", }, diff --git a/pkg/controller/common/annotation/association.go b/pkg/controller/common/annotation/association.go index d1995b16ce..cd032e66bf 100644 --- a/pkg/controller/common/annotation/association.go +++ b/pkg/controller/common/annotation/association.go @@ -5,7 +5,7 @@ package annotation import ( - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -19,7 +19,7 @@ const ( ) // ForAssociationStatusChange constructs the annotation map for an association status change event. -func ForAssociationStatusChange(prevStatus, currStatus commonv1alpha1.AssociationStatus) map[string]string { +func ForAssociationStatusChange(prevStatus, currStatus commonv1beta1.AssociationStatus) map[string]string { return map[string]string{ CurrAssocStatusAnnotation: string(currStatus), PrevAssocStatusAnnotation: string(prevStatus), @@ -27,12 +27,12 @@ func ForAssociationStatusChange(prevStatus, currStatus commonv1alpha1.Associatio } // ExtractAssociationStatus extracts the association status values from the provided meta object. -func ExtractAssociationStatus(obj metav1.ObjectMeta) (prevStatus, currStatus commonv1alpha1.AssociationStatus) { +func ExtractAssociationStatus(obj metav1.ObjectMeta) (prevStatus, currStatus commonv1beta1.AssociationStatus) { if obj.Annotations == nil { - return commonv1alpha1.AssociationUnknown, commonv1alpha1.AssociationUnknown + return commonv1beta1.AssociationUnknown, commonv1beta1.AssociationUnknown } - prevStatus = commonv1alpha1.AssociationStatus(obj.Annotations[PrevAssocStatusAnnotation]) - currStatus = commonv1alpha1.AssociationStatus(obj.Annotations[CurrAssocStatusAnnotation]) + prevStatus = commonv1beta1.AssociationStatus(obj.Annotations[PrevAssocStatusAnnotation]) + currStatus = commonv1beta1.AssociationStatus(obj.Annotations[CurrAssocStatusAnnotation]) return } diff --git a/pkg/controller/common/annotation/controller_version.go b/pkg/controller/common/annotation/controller_version.go index ec79a47172..b3e6a62894 100644 --- a/pkg/controller/common/annotation/controller_version.go +++ b/pkg/controller/common/annotation/controller_version.go @@ -14,8 +14,14 @@ import ( ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" ) -// ControllerVersionAnnotation is the annotation name that indicates the last controller version to update a resource -const ControllerVersionAnnotation = "common.k8s.elastic.co/controller-version" +const ( + // ControllerVersionAnnotation is the annotation name that indicates the last controller version to update a resource + ControllerVersionAnnotation = "common.k8s.elastic.co/controller-version" + // UnknownControllerVersion is the version used when a resource has been created before we started adding the annotation + UnknownControllerVersion = "0.0.0-UNKNOWN" // may match resources created with ECK-0.8.0 + // MinCompatibleControllerVersion is the minimum version that indicates that a resource is compatible with this operator + MinCompatibleControllerVersion = "0.10.0-SNAPSHOT" +) // UpdateControllerVersion updates the controller version annotation to the current version if necessary func UpdateControllerVersion(client k8s.Client, obj runtime.Object, version string) error { @@ -87,7 +93,7 @@ func ReconcileCompatibility(client k8s.Client, obj runtime.Object, selector map[ } if exist { log.Info("Resource was previously reconciled by incompatible controller version and missing annotation, adding annotation", "controller_version", controllerVersion, "namespace", namespace, "name", name, "kind", obj.GetObjectKind().GroupVersionKind().Kind) - err = UpdateControllerVersion(client, obj, "0.8.0-UNKNOWN") + err = UpdateControllerVersion(client, obj, UnknownControllerVersion) return false, err } // no annotation exists and there are no existing resources, so this has not previously been reconciled @@ -99,7 +105,7 @@ func ReconcileCompatibility(client k8s.Client, obj runtime.Object, selector map[ if err != nil { return false, errors.Wrap(err, "Error parsing current version on resource") } - minVersion, err := version.Parse("0.9.0-ALPHA") + minVersion, err := version.Parse(MinCompatibleControllerVersion) if err != nil { return false, errors.Wrap(err, "Error parsing minimum compatible version") } diff --git a/pkg/controller/common/annotation/controller_version_test.go b/pkg/controller/common/annotation/controller_version_test.go index e5921ab5a7..cc3f5d4f6d 100644 --- a/pkg/controller/common/annotation/controller_version_test.go +++ b/pkg/controller/common/annotation/controller_version_test.go @@ -7,7 +7,7 @@ package annotation import ( "testing" - kibanav1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kibanav1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -19,15 +19,15 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client/fake" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "k8s.io/client-go/kubernetes/scheme" ) // Test UpdateControllerVersion updates annotation if there is an older version func TestAnnotationUpdated(t *testing.T) { - kibana := kibanav1alpha1.Kibana{ + kibana := kibanav1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "kibana", @@ -46,7 +46,7 @@ func TestAnnotationUpdated(t *testing.T) { // Test UpdateControllerVersion creates an annotation even if there are no current annotations func TestAnnotationCreated(t *testing.T) { - kibana := kibanav1alpha1.Kibana{ + kibana := kibanav1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "kibana", @@ -58,7 +58,7 @@ func TestAnnotationCreated(t *testing.T) { client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, obj)) err := UpdateControllerVersion(client, obj, "newversion") require.NoError(t, err) - actualKibana := &kibanav1alpha1.Kibana{} + actualKibana := &kibanav1beta1.Kibana{} err = client.Get(types.NamespacedName{ Namespace: obj.Namespace, Name: obj.Name, @@ -72,7 +72,7 @@ func TestAnnotationCreated(t *testing.T) { // a previous operator version, and add an annotation indicating an old controller version func TestMissingAnnotationOldVersion(t *testing.T) { - es := &v1alpha1.Elasticsearch{ + es := &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "es", @@ -90,18 +90,18 @@ func TestMissingAnnotationOldVersion(t *testing.T) { sc := setupScheme(t) client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, es, svc)) selector := getElasticsearchSelector(es) - compat, err := ReconcileCompatibility(client, es, selector, "0.9.0-SNAPSHOT") + compat, err := ReconcileCompatibility(client, es, selector, MinCompatibleControllerVersion) require.NoError(t, err) assert.False(t, compat) // check old version annotation was added require.NotNil(t, es.Annotations) - assert.Equal(t, "0.8.0-UNKNOWN", es.Annotations[ControllerVersionAnnotation]) + assert.Equal(t, UnknownControllerVersion, es.Annotations[ControllerVersionAnnotation]) } // TestMissingAnnotationNewObject tests that we add an annotation for new objects func TestMissingAnnotationNewObject(t *testing.T) { - es := &v1alpha1.Elasticsearch{ + es := &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "es", @@ -126,37 +126,37 @@ func TestMissingAnnotationNewObject(t *testing.T) { // client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, es, svc)) client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, es)) selector := getElasticsearchSelector(es) - compat, err := ReconcileCompatibility(client, es, selector, "0.9.0-SNAPSHOT") + compat, err := ReconcileCompatibility(client, es, selector, MinCompatibleControllerVersion) require.NoError(t, err) assert.True(t, compat) // check version annotation was added require.NotNil(t, es.Annotations) - assert.Equal(t, "0.9.0-SNAPSHOT", es.Annotations[ControllerVersionAnnotation]) + assert.Equal(t, MinCompatibleControllerVersion, es.Annotations[ControllerVersionAnnotation]) } // func TestSameAnnotation(t *testing.T) { - es := &v1alpha1.Elasticsearch{ + es := &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "es", Annotations: map[string]string{ - ControllerVersionAnnotation: "0.9.0-SNAPSHOT", + ControllerVersionAnnotation: MinCompatibleControllerVersion, }, }, } sc := setupScheme(t) client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, es)) selector := getElasticsearchSelector(es) - compat, err := ReconcileCompatibility(client, es, selector, "0.9.0-SNAPSHOT") + compat, err := ReconcileCompatibility(client, es, selector, MinCompatibleControllerVersion) require.NoError(t, err) assert.True(t, compat) - assert.Equal(t, "0.9.0-SNAPSHOT", es.Annotations[ControllerVersionAnnotation]) + assert.Equal(t, MinCompatibleControllerVersion, es.Annotations[ControllerVersionAnnotation]) } func TestIncompatibleAnnotation(t *testing.T) { - es := &v1alpha1.Elasticsearch{ + es := &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "es", @@ -168,7 +168,7 @@ func TestIncompatibleAnnotation(t *testing.T) { sc := setupScheme(t) client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, es)) selector := getElasticsearchSelector(es) - compat, err := ReconcileCompatibility(client, es, selector, "0.9.0-SNAPSHOT") + compat, err := ReconcileCompatibility(client, es, selector, MinCompatibleControllerVersion) require.NoError(t, err) assert.False(t, compat) // check we did not update the annotation @@ -176,7 +176,7 @@ func TestIncompatibleAnnotation(t *testing.T) { } func TestNewerAnnotation(t *testing.T) { - es := &v1alpha1.Elasticsearch{ + es := &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "es", @@ -188,7 +188,7 @@ func TestNewerAnnotation(t *testing.T) { sc := setupScheme(t) client := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, es)) selector := getElasticsearchSelector(es) - compat, err := ReconcileCompatibility(client, es, selector, "0.9.0-SNAPSHOT") + compat, err := ReconcileCompatibility(client, es, selector, MinCompatibleControllerVersion) assert.NoError(t, err) assert.True(t, compat) } @@ -200,11 +200,11 @@ func setupScheme(t *testing.T) *runtime.Scheme { require.NoError(t, err) err = estype.SchemeBuilder.AddToScheme(sc) require.NoError(t, err) - err = kibanav1alpha1.SchemeBuilder.AddToScheme(sc) + err = kibanav1beta1.SchemeBuilder.AddToScheme(sc) require.NoError(t, err) return sc } -func getElasticsearchSelector(es *v1alpha1.Elasticsearch) map[string]string { +func getElasticsearchSelector(es *v1beta1.Elasticsearch) map[string]string { return map[string]string{label.ClusterNameLabelName: es.Name} } diff --git a/pkg/controller/common/association/association.go b/pkg/controller/common/association/association.go index 7f4224518c..f14921085f 100644 --- a/pkg/controller/common/association/association.go +++ b/pkg/controller/common/association/association.go @@ -5,7 +5,7 @@ package association import ( - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -15,7 +15,7 @@ import ( // against an Elasticsearch cluster. func ElasticsearchAuthSettings( c k8s.Client, - associated commonv1alpha1.Associated, + associated commonv1beta1.Associated, ) (username, password string, err error) { assocConf := associated.AssociationConf() if !assocConf.AuthIsConfigured() { diff --git a/pkg/controller/common/association/association_test.go b/pkg/controller/common/association/association_test.go index 73387a4a75..2e6bac29f8 100644 --- a/pkg/controller/common/association/association_test.go +++ b/pkg/controller/common/association/association_test.go @@ -7,8 +7,8 @@ package association import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -16,22 +16,22 @@ import ( ) func TestGetCredentials(t *testing.T) { - apmServer := &v1alpha1.ApmServer{ + apmServer := &v1beta1.ApmServer{ ObjectMeta: metav1.ObjectMeta{ Name: "apm-server-sample", Namespace: "default", }, - Spec: v1alpha1.ApmServerSpec{}, + Spec: v1beta1.ApmServerSpec{}, } - apmServer.SetAssociationConf(&commonv1alpha1.AssociationConf{ + apmServer.SetAssociationConf(&commonv1beta1.AssociationConf{ URL: "https://elasticsearch-sample-es-http.default.svc:9200", }) tests := []struct { name string client k8s.Client - assocConf commonv1alpha1.AssociationConf + assocConf commonv1beta1.AssociationConf wantUsername string wantPassword string wantErr bool @@ -45,7 +45,7 @@ func TestGetCredentials(t *testing.T) { }, Data: map[string][]byte{"elastic-internal-apm": []byte("a2s1Nmt0N3Nwdmg4cmpqdDlucWhsN3cy")}, })), - assocConf: commonv1alpha1.AssociationConf{ + assocConf: commonv1beta1.AssociationConf{ AuthSecretName: "apmelasticsearchassociation-sample-elastic-internal-apm", AuthSecretKey: "elastic-internal-apm", CASecretName: "ca-secret", @@ -63,7 +63,7 @@ func TestGetCredentials(t *testing.T) { }, Data: map[string][]byte{"elastic-internal-apm": []byte("a2s1Nmt0N3Nwdmg4cmpqdDlucWhsN3cy")}, })), - assocConf: commonv1alpha1.AssociationConf{ + assocConf: commonv1beta1.AssociationConf{ CASecretName: "ca-secret", URL: "https://elasticsearch-sample-es-http.default.svc:9200", }, @@ -77,7 +77,7 @@ func TestGetCredentials(t *testing.T) { }, Data: map[string][]byte{"elastic-internal-apm": []byte("a2s1Nmt0N3Nwdmg4cmpqdDlucWhsN3cy")}, })), - assocConf: commonv1alpha1.AssociationConf{ + assocConf: commonv1beta1.AssociationConf{ AuthSecretName: "apmelasticsearchassociation-sample-elastic-internal-apm", AuthSecretKey: "elastic-internal-apm", CASecretName: "ca-secret", diff --git a/pkg/controller/common/association/ca.go b/pkg/controller/common/association/ca.go index 710d55e8e6..c227f2f1bb 100644 --- a/pkg/controller/common/association/ca.go +++ b/pkg/controller/common/association/ca.go @@ -7,7 +7,7 @@ package association import ( "reflect" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" @@ -28,7 +28,7 @@ type CASecret struct { // ElasticsearchCACertSecretName returns the name of the secret holding the certificate chain used // by the associated resource to establish and validate a secured HTTP connection to Elasticsearch. -func ElasticsearchCACertSecretName(associated commonv1alpha1.Associated, suffix string) string { +func ElasticsearchCACertSecretName(associated commonv1beta1.Associated, suffix string) string { return associated.GetName() + "-" + suffix } @@ -37,7 +37,7 @@ func ElasticsearchCACertSecretName(associated commonv1alpha1.Associated, suffix func ReconcileCASecret( client k8s.Client, scheme *runtime.Scheme, - associated commonv1alpha1.Associated, + associated commonv1beta1.Associated, es types.NamespacedName, labels map[string]string, suffix string, diff --git a/pkg/controller/common/association/ca_test.go b/pkg/controller/common/association/ca_test.go index 74e1e854f3..aef97034e0 100644 --- a/pkg/controller/common/association/ca_test.go +++ b/pkg/controller/common/association/ca_test.go @@ -7,8 +7,8 @@ package association import ( "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/watches" esname "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" diff --git a/pkg/controller/common/association/conf.go b/pkg/controller/common/association/conf.go index 6e3b4ad693..aa403764a0 100644 --- a/pkg/controller/common/association/conf.go +++ b/pkg/controller/common/association/conf.go @@ -9,7 +9,7 @@ import ( "reflect" "unsafe" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/pkg/errors" @@ -20,7 +20,7 @@ import ( ) // FetchWithAssociation retrieves an object and extracts its association configuration. -func FetchWithAssociation(client k8s.Client, request reconcile.Request, obj commonv1alpha1.Associator) (bool, error) { +func FetchWithAssociation(client k8s.Client, request reconcile.Request, obj commonv1beta1.Associator) (bool, error) { if err := client.Get(request.NamespacedName, obj); err != nil { if apierrors.IsNotFound(err) { return false, nil @@ -38,7 +38,7 @@ func FetchWithAssociation(client k8s.Client, request reconcile.Request, obj comm } // GetAssociationConf extracts the association configuration from the given object by reading the annotations. -func GetAssociationConf(obj runtime.Object) (*commonv1alpha1.AssociationConf, error) { +func GetAssociationConf(obj runtime.Object) (*commonv1beta1.AssociationConf, error) { accessor := meta.NewAccessor() annotations, err := accessor.Annotations(obj) if err != nil { @@ -48,12 +48,12 @@ func GetAssociationConf(obj runtime.Object) (*commonv1alpha1.AssociationConf, er return extractAssociationConf(annotations) } -func extractAssociationConf(annotations map[string]string) (*commonv1alpha1.AssociationConf, error) { +func extractAssociationConf(annotations map[string]string) (*commonv1beta1.AssociationConf, error) { if len(annotations) == 0 { return nil, nil } - var assocConf commonv1alpha1.AssociationConf + var assocConf commonv1beta1.AssociationConf serializedConf, exists := annotations[annotation.AssociationConfAnnotation] if !exists || serializedConf == "" { return nil, nil @@ -91,7 +91,7 @@ func RemoveAssociationConf(client k8s.Client, obj runtime.Object) error { } // UpdateAssociationConf updates the association configuration annotation. -func UpdateAssociationConf(client k8s.Client, obj runtime.Object, wantConf *commonv1alpha1.AssociationConf) error { +func UpdateAssociationConf(client k8s.Client, obj runtime.Object, wantConf *commonv1beta1.AssociationConf) error { accessor := meta.NewAccessor() annotations, err := accessor.Annotations(obj) if err != nil { diff --git a/pkg/controller/common/association/conf_test.go b/pkg/controller/common/association/conf_test.go index 1e218d9519..c18f8fe450 100644 --- a/pkg/controller/common/association/conf_test.go +++ b/pkg/controller/common/association/conf_test.go @@ -7,9 +7,9 @@ package association import ( "testing" - apmv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - kbv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + apmv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + kbv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/require" @@ -26,22 +26,22 @@ func TestFetchWithAssociation(t *testing.T) { } func testFetchAPMServer(t *testing.T) { - require.NoError(t, apmv1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, apmv1beta1.AddToScheme(scheme.Scheme)) testCases := []struct { name string - apmServer *apmv1alpha1.ApmServer + apmServer *apmv1beta1.ApmServer request reconcile.Request wantOK bool wantErr bool - wantAssocConf *commonv1alpha1.AssociationConf + wantAssocConf *commonv1beta1.AssociationConf }{ { name: "with association annotation", apmServer: mkAPMServer(true), request: reconcile.Request{NamespacedName: types.NamespacedName{Name: "apm-server-test", Namespace: "apm-ns"}}, wantOK: true, - wantAssocConf: &commonv1alpha1.AssociationConf{ + wantAssocConf: &commonv1beta1.AssociationConf{ AuthSecretName: "auth-secret", AuthSecretKey: "apm-user", CASecretName: "ca-secret", @@ -66,7 +66,7 @@ func testFetchAPMServer(t *testing.T) { t.Run(tc.name, func(t *testing.T) { client := k8s.WrapClient(fake.NewFakeClient(tc.apmServer)) - var got apmv1alpha1.ApmServer + var got apmv1beta1.ApmServer ok, err := FetchWithAssociation(client, tc.request, &got) if tc.wantErr { @@ -86,13 +86,13 @@ func testFetchAPMServer(t *testing.T) { } } -func mkAPMServer(withAnnotations bool) *apmv1alpha1.ApmServer { - apmServer := &apmv1alpha1.ApmServer{ +func mkAPMServer(withAnnotations bool) *apmv1beta1.ApmServer { + apmServer := &apmv1beta1.ApmServer{ ObjectMeta: metav1.ObjectMeta{ Name: "apm-server-test", Namespace: "apm-ns", }, - Spec: apmv1alpha1.ApmServerSpec{ + Spec: apmv1beta1.ApmServerSpec{ Image: "test-image", NodeCount: 1, }, @@ -108,22 +108,22 @@ func mkAPMServer(withAnnotations bool) *apmv1alpha1.ApmServer { } func testFetchKibana(t *testing.T) { - require.NoError(t, kbv1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, kbv1beta1.AddToScheme(scheme.Scheme)) testCases := []struct { name string - kibana *kbv1alpha1.Kibana + kibana *kbv1beta1.Kibana request reconcile.Request wantOK bool wantErr bool - wantAssocConf *commonv1alpha1.AssociationConf + wantAssocConf *commonv1beta1.AssociationConf }{ { name: "with association annotation", kibana: mkKibana(true), request: reconcile.Request{NamespacedName: types.NamespacedName{Name: "kb-test", Namespace: "kb-ns"}}, wantOK: true, - wantAssocConf: &commonv1alpha1.AssociationConf{ + wantAssocConf: &commonv1beta1.AssociationConf{ AuthSecretName: "auth-secret", AuthSecretKey: "kb-user", CASecretName: "ca-secret", @@ -148,7 +148,7 @@ func testFetchKibana(t *testing.T) { t.Run(tc.name, func(t *testing.T) { client := k8s.WrapClient(fake.NewFakeClient(tc.kibana)) - var got kbv1alpha1.Kibana + var got kbv1beta1.Kibana ok, err := FetchWithAssociation(client, tc.request, &got) if tc.wantErr { @@ -168,13 +168,13 @@ func testFetchKibana(t *testing.T) { } } -func mkKibana(withAnnotations bool) *kbv1alpha1.Kibana { - kb := &kbv1alpha1.Kibana{ +func mkKibana(withAnnotations bool) *kbv1beta1.Kibana { + kb := &kbv1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Name: "kb-test", Namespace: "kb-ns", }, - Spec: kbv1alpha1.KibanaSpec{ + Spec: kbv1beta1.KibanaSpec{ Image: "test-image", NodeCount: 1, }, @@ -190,12 +190,12 @@ func mkKibana(withAnnotations bool) *kbv1alpha1.Kibana { } func TestUpdateAssociationConf(t *testing.T) { - require.NoError(t, kbv1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, kbv1beta1.AddToScheme(scheme.Scheme)) kb := mkKibana(true) request := reconcile.Request{NamespacedName: types.NamespacedName{Name: "kb-test", Namespace: "kb-ns"}} client := k8s.WrapClient(fake.NewFakeClient(kb)) - assocConf := &commonv1alpha1.AssociationConf{ + assocConf := &commonv1beta1.AssociationConf{ AuthSecretName: "auth-secret", AuthSecretKey: "kb-user", CASecretName: "ca-secret", @@ -203,7 +203,7 @@ func TestUpdateAssociationConf(t *testing.T) { } // check the existing values - var got kbv1alpha1.Kibana + var got kbv1beta1.Kibana ok, _ := FetchWithAssociation(client, request, &got) require.True(t, ok) require.Equal(t, "kb-test", got.Name) @@ -213,7 +213,7 @@ func TestUpdateAssociationConf(t *testing.T) { require.Equal(t, assocConf, got.AssociationConf()) // update and check the new values - newAssocConf := &commonv1alpha1.AssociationConf{ + newAssocConf := &commonv1beta1.AssociationConf{ AuthSecretName: "new-auth-secret", AuthSecretKey: "new-kb-user", CASecretName: "new-ca-secret", @@ -233,12 +233,12 @@ func TestUpdateAssociationConf(t *testing.T) { } func TestRemoveAssociationConf(t *testing.T) { - require.NoError(t, kbv1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, kbv1beta1.AddToScheme(scheme.Scheme)) kb := mkKibana(true) request := reconcile.Request{NamespacedName: types.NamespacedName{Name: "kb-test", Namespace: "kb-ns"}} client := k8s.WrapClient(fake.NewFakeClient(kb)) - assocConf := &commonv1alpha1.AssociationConf{ + assocConf := &commonv1beta1.AssociationConf{ AuthSecretName: "auth-secret", AuthSecretKey: "kb-user", CASecretName: "ca-secret", @@ -246,7 +246,7 @@ func TestRemoveAssociationConf(t *testing.T) { } // check the existing values - var got kbv1alpha1.Kibana + var got kbv1beta1.Kibana ok, _ := FetchWithAssociation(client, request, &got) require.True(t, ok) require.Equal(t, "kb-test", got.Name) diff --git a/pkg/controller/common/association/user.go b/pkg/controller/common/association/user.go index b4883aac4b..2b19d8f611 100644 --- a/pkg/controller/common/association/user.go +++ b/pkg/controller/common/association/user.go @@ -7,8 +7,8 @@ package association import ( "bytes" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" commonuser "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -20,7 +20,7 @@ import ( ) // elasticsearchUserName identifies the associated user in Elasticsearch namespace. -func elasticsearchUserName(associated commonv1alpha1.Associated, userSuffix string) string { +func elasticsearchUserName(associated commonv1beta1.Associated, userSuffix string) string { // must be namespace-aware since we might have several associated instances running in // different namespaces with the same name: we need one user for each // in the Elasticsearch namespace @@ -28,13 +28,13 @@ func elasticsearchUserName(associated commonv1alpha1.Associated, userSuffix stri } // userSecretObjectName identifies the associated secret object. -func userSecretObjectName(associated commonv1alpha1.Associated, userSuffix string) string { +func userSecretObjectName(associated commonv1beta1.Associated, userSuffix string) string { // does not need to be namespace aware, since it lives in associated object namespace. return associated.GetName() + "-" + userSuffix } // UserKey is the namespaced name to identify the user resource created by the controller. -func UserKey(associated commonv1alpha1.Associated, userSuffix string) types.NamespacedName { +func UserKey(associated commonv1beta1.Associated, userSuffix string) types.NamespacedName { esNamespace := associated.ElasticsearchRef().Namespace if esNamespace == "" { // no namespace given, default to the associated object's one @@ -49,7 +49,7 @@ func UserKey(associated commonv1alpha1.Associated, userSuffix string) types.Name // secretKey is the namespaced name to identify the secret containing the password for the user. // It uses the same resource name as the associated user. -func secretKey(associated commonv1alpha1.Associated, userSuffix string) types.NamespacedName { +func secretKey(associated commonv1beta1.Associated, userSuffix string) types.NamespacedName { return types.NamespacedName{ Namespace: associated.GetNamespace(), Name: userSecretObjectName(associated, userSuffix), @@ -57,7 +57,7 @@ func secretKey(associated commonv1alpha1.Associated, userSuffix string) types.Na } // ClearTextSecretKeySelector creates a SecretKeySelector for the associated user secret -func ClearTextSecretKeySelector(associated commonv1alpha1.Associated, userSuffix string) *corev1.SecretKeySelector { +func ClearTextSecretKeySelector(associated commonv1beta1.Associated, userSuffix string) *corev1.SecretKeySelector { return &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ Name: userSecretObjectName(associated, userSuffix), @@ -70,11 +70,11 @@ func ClearTextSecretKeySelector(associated commonv1alpha1.Associated, userSuffix func ReconcileEsUser( c k8s.Client, s *runtime.Scheme, - associated commonv1alpha1.Associated, + associated commonv1beta1.Associated, labels map[string]string, userRoles string, userObjectSuffix string, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, ) error { pw := commonuser.RandomPasswordBytes() diff --git a/pkg/controller/common/association/user_test.go b/pkg/controller/common/association/user_test.go index e7a6fb9555..8e4678ab42 100644 --- a/pkg/controller/common/association/user_test.go +++ b/pkg/controller/common/association/user_test.go @@ -7,9 +7,9 @@ package association import ( "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" @@ -53,7 +53,7 @@ var kibanaFixtureObjectMeta = metav1.ObjectMeta{ var kibanaFixture = kbtype.Kibana{ ObjectMeta: kibanaFixtureObjectMeta, Spec: kbtype.KibanaSpec{ - ElasticsearchRef: commonv1alpha1.ObjectSelector{ + ElasticsearchRef: commonv1beta1.ObjectSelector{ Name: esFixture.Name, Namespace: esFixture.Namespace, }, @@ -238,7 +238,7 @@ func Test_reconcileEsUser(t *testing.T) { Namespace: "ns-2", }, Spec: kbtype.KibanaSpec{ - ElasticsearchRef: commonv1alpha1.ObjectSelector{ + ElasticsearchRef: commonv1beta1.ObjectSelector{ Name: esFixture.Name, Namespace: esFixture.Namespace, }, diff --git a/pkg/controller/common/certificates/ca_reconcile_test.go b/pkg/controller/common/certificates/ca_reconcile_test.go index e72c569de5..d32455963a 100644 --- a/pkg/controller/common/certificates/ca_reconcile_test.go +++ b/pkg/controller/common/certificates/ca_reconcile_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/assert" @@ -34,7 +34,7 @@ var testNamer = name.Namer{ var ( testNamespace = "test-namespace" testName = "test-name" - testCluster = v1alpha1.Elasticsearch{ + testCluster = v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNamespace, Name: testName, @@ -145,7 +145,7 @@ func Test_canReuseCA(t *testing.T) { func checkCASecrets( t *testing.T, client k8s.Client, - cluster v1alpha1.Elasticsearch, + cluster v1beta1.Elasticsearch, caType CAType, ca *CA, expectedCa *CA, @@ -195,7 +195,7 @@ func Test_renewCA(t *testing.T) { require.NoError(t, err) internalCASecret := internalSecretForCA(testCa, testNamer, &testCluster, nil, TransportCAType) - err = v1alpha1.AddToScheme(scheme.Scheme) + err = v1beta1.AddToScheme(scheme.Scheme) require.NoError(t, err) tests := []struct { @@ -228,7 +228,7 @@ func Test_renewCA(t *testing.T) { } func TestReconcileCAForCluster(t *testing.T) { - err := v1alpha1.AddToScheme(scheme.Scheme) + err := v1beta1.AddToScheme(scheme.Scheme) require.NoError(t, err) validCa, err := NewSelfSignedCA(CABuilderOptions{}) diff --git a/pkg/controller/common/certificates/http/certificates_secret.go b/pkg/controller/common/certificates/http/certificates_secret.go index 7da3fba4d8..9b23f45e35 100644 --- a/pkg/controller/common/certificates/http/certificates_secret.go +++ b/pkg/controller/common/certificates/http/certificates_secret.go @@ -7,7 +7,7 @@ package http import ( "fmt" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" v1 "k8s.io/api/core/v1" @@ -71,7 +71,7 @@ func (s CertificatesSecret) Validate() error { func GetCustomCertificates( c k8s.Client, owner types.NamespacedName, - tls v1alpha1.TLSOptions, + tls v1beta1.TLSOptions, ) (*CertificatesSecret, error) { secretName := tls.Certificate.SecretName if secretName == "" { diff --git a/pkg/controller/common/certificates/http/dynamic_watches.go b/pkg/controller/common/certificates/http/dynamic_watches.go index 6a880d0045..826c9b9a97 100644 --- a/pkg/controller/common/certificates/http/dynamic_watches.go +++ b/pkg/controller/common/certificates/http/dynamic_watches.go @@ -7,7 +7,7 @@ package http import ( "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/finalizer" "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" "github.com/elastic/cloud-on-k8s/pkg/controller/common/watches" @@ -20,7 +20,7 @@ func httpCertificateWatchKey(namer name.Namer, ownerName string) string { } // reconcileDynamicWatches reconciles the dynamic watches needed by the HTTP certificates. -func reconcileDynamicWatches(dynamicWatches watches.DynamicWatches, owner types.NamespacedName, namer name.Namer, tls v1alpha1.TLSOptions) error { +func reconcileDynamicWatches(dynamicWatches watches.DynamicWatches, owner types.NamespacedName, namer name.Namer, tls v1beta1.TLSOptions) error { // watch the Secret specified in es.Spec.HTTP.TLS.Certificate because if it changes we should reconcile the new // user provided certificates. httpCertificateWatch := watches.NamedWatch{ diff --git a/pkg/controller/common/certificates/http/public_secret_test.go b/pkg/controller/common/certificates/http/public_secret_test.go index 6506638efa..4cc4313ed8 100644 --- a/pkg/controller/common/certificates/http/public_secret_test.go +++ b/pkg/controller/common/certificates/http/public_secret_test.go @@ -8,7 +8,7 @@ import ( "encoding/json" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -26,7 +26,7 @@ func TestReconcileHTTPCertsPublicSecret(t *testing.T) { tls := loadFileBytes("tls.crt") key := loadFileBytes("tls.key") - owner := &v1alpha1.Elasticsearch{ + owner := &v1beta1.Elasticsearch{ ObjectMeta: v1.ObjectMeta{Name: "test-es-name", Namespace: "test-namespace"}, } diff --git a/pkg/controller/common/certificates/http/reconcile.go b/pkg/controller/common/certificates/http/reconcile.go index 74219d0e97..f0a988ccd8 100644 --- a/pkg/controller/common/certificates/http/reconcile.go +++ b/pkg/controller/common/certificates/http/reconcile.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" @@ -39,7 +39,7 @@ func ReconcileHTTPCertificates( owner metav1.Object, namer name.Namer, ca *certificates.CA, - tls v1alpha1.TLSOptions, + tls v1beta1.TLSOptions, labels map[string]string, services []corev1.Service, rotationParams certificates.RotationParams, @@ -70,7 +70,7 @@ func reconcileHTTPInternalCertificatesSecret( scheme *runtime.Scheme, owner metav1.Object, namer name.Namer, - tls v1alpha1.TLSOptions, + tls v1beta1.TLSOptions, labels map[string]string, svcs []corev1.Service, customCertificates *CertificatesSecret, @@ -166,7 +166,7 @@ func ensureInternalSelfSignedCertificateSecretContents( secret *corev1.Secret, owner types.NamespacedName, namer name.Namer, - tls v1alpha1.TLSOptions, + tls v1beta1.TLSOptions, svcs []corev1.Service, ca *certificates.CA, rotationParam certificates.RotationParams, @@ -249,7 +249,7 @@ func ensureInternalSelfSignedCertificateSecretContents( func shouldIssueNewHTTPCertificate( owner types.NamespacedName, namer name.Namer, - tls v1alpha1.TLSOptions, + tls v1beta1.TLSOptions, secret *corev1.Secret, svcs []corev1.Service, ca *certificates.CA, @@ -328,7 +328,7 @@ func shouldIssueNewHTTPCertificate( func createValidatedHTTPCertificateTemplate( owner types.NamespacedName, namer name.Namer, - tls v1alpha1.TLSOptions, + tls v1beta1.TLSOptions, svcs []corev1.Service, csr *x509.CertificateRequest, certValidity time.Duration, diff --git a/pkg/controller/common/certificates/http/reconcile_test.go b/pkg/controller/common/certificates/http/reconcile_test.go index 139376a52f..803864f056 100644 --- a/pkg/controller/common/certificates/http/reconcile_test.go +++ b/pkg/controller/common/certificates/http/reconcile_test.go @@ -14,8 +14,8 @@ import ( "testing" "time" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" "github.com/elastic/cloud-on-k8s/pkg/controller/common/watches" @@ -54,7 +54,7 @@ var ( testCA *certificates.CA testRSAPrivateKey *rsa.PrivateKey pemCert []byte - testES = v1alpha1.Elasticsearch{ObjectMeta: v1.ObjectMeta{Name: "test-es-name", Namespace: "test-namespace"}} + testES = v1beta1.Elasticsearch{ObjectMeta: v1.ObjectMeta{Name: "test-es-name", Namespace: "test-namespace"}} testSvc = corev1.Service{ ObjectMeta: v1.ObjectMeta{ Name: "test-service", @@ -67,7 +67,7 @@ var ( ) func init() { - if err := v1alpha1.AddToScheme(scheme.Scheme); err != nil { + if err := v1beta1.AddToScheme(scheme.Scheme); err != nil { panic(err) } @@ -108,7 +108,7 @@ func TestReconcileHTTPCertificates(t *testing.T) { type args struct { c k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch ca *certificates.CA services []corev1.Service } @@ -140,12 +140,12 @@ func TestReconcileHTTPCertificates(t *testing.T) { certificates.KeyFileName: key, }, })), - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: v1.ObjectMeta{Name: "test-es-name", Namespace: "test-namespace"}, - Spec: v1alpha1.ElasticsearchSpec{ - HTTP: commonv1alpha1.HTTPConfig{ - TLS: commonv1alpha1.TLSOptions{ - Certificate: commonv1alpha1.SecretRef{ + Spec: v1beta1.ElasticsearchSpec{ + HTTP: commonv1beta1.HTTPConfig{ + TLS: commonv1beta1.TLSOptions{ + Certificate: commonv1beta1.SecretRef{ SecretName: "my-cert", }, }, @@ -193,7 +193,7 @@ func Test_createValidatedHTTPCertificateTemplate(t *testing.T) { sanIPv6 := "2001:db8:0:85a3:0:0:ac1f:8001" type args struct { - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch svcs []corev1.Service certValidity time.Duration } @@ -205,13 +205,13 @@ func Test_createValidatedHTTPCertificateTemplate(t *testing.T) { { name: "with svcs and user-provided SANs", args: args{ - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: v1.ObjectMeta{Namespace: "test", Name: "test"}, - Spec: v1alpha1.ElasticsearchSpec{ - HTTP: commonv1alpha1.HTTPConfig{ - TLS: commonv1alpha1.TLSOptions{ - SelfSignedCertificate: &commonv1alpha1.SelfSignedCertificate{ - SubjectAlternativeNames: []commonv1alpha1.SubjectAlternativeName{ + Spec: v1beta1.ElasticsearchSpec{ + HTTP: commonv1beta1.HTTPConfig{ + TLS: commonv1beta1.TLSOptions{ + SelfSignedCertificate: &commonv1beta1.SelfSignedCertificate{ + SubjectAlternativeNames: []commonv1beta1.SubjectAlternativeName{ { DNS: sanDNS1, }, @@ -273,10 +273,10 @@ func Test_createValidatedHTTPCertificateTemplate(t *testing.T) { func Test_shouldIssueNewCertificate(t *testing.T) { esWithSAN := testES.DeepCopy() - esWithSAN.Spec.HTTP = commonv1alpha1.HTTPConfig{ - TLS: commonv1alpha1.TLSOptions{ - SelfSignedCertificate: &commonv1alpha1.SelfSignedCertificate{ - SubjectAlternativeNames: []commonv1alpha1.SubjectAlternativeName{ + esWithSAN.Spec.HTTP = commonv1beta1.HTTPConfig{ + TLS: commonv1beta1.TLSOptions{ + SelfSignedCertificate: &commonv1beta1.SelfSignedCertificate{ + SubjectAlternativeNames: []commonv1beta1.SubjectAlternativeName{ { DNS: "search.example.com", }, @@ -285,7 +285,7 @@ func Test_shouldIssueNewCertificate(t *testing.T) { }, } type args struct { - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch secret corev1.Secret rotateBefore time.Duration } diff --git a/pkg/controller/common/deployment/reconcile_test.go b/pkg/controller/common/deployment/reconcile_test.go index 9da1229c38..b14455b3f2 100644 --- a/pkg/controller/common/deployment/reconcile_test.go +++ b/pkg/controller/common/deployment/reconcile_test.go @@ -7,13 +7,13 @@ package deployment import ( "testing" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" commonscheme "github.com/elastic/cloud-on-k8s/pkg/controller/common/scheme" @@ -63,7 +63,7 @@ func TestReconcile(t *testing.T) { Replicas: common.Int32(2), }, } - owner := v1alpha1.Elasticsearch{} // can be any type + owner := v1beta1.Elasticsearch{} // can be any type // should create a new deployment reconciled, err := Reconcile(k8sClient, scheme.Scheme, expected, &owner) diff --git a/pkg/controller/common/keystore/resources.go b/pkg/controller/common/keystore/resources.go index 99b7c764af..59f1fc7b00 100644 --- a/pkg/controller/common/keystore/resources.go +++ b/pkg/controller/common/keystore/resources.go @@ -7,7 +7,7 @@ package keystore import ( "strings" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" corev1 "k8s.io/api/core/v1" @@ -33,7 +33,7 @@ type Resources struct { type HasKeystore interface { metav1.Object runtime.Object - SecureSettings() []commonv1alpha1.SecretSource + SecureSettings() []commonv1beta1.SecretSource // Kind can technically be retrieved from metav1.Object, but there is a bug preventing us to retrieve it // see https://github.com/kubernetes-sigs/controller-runtime/issues/406 Kind() string diff --git a/pkg/controller/common/keystore/resources_test.go b/pkg/controller/common/keystore/resources_test.go index cb7c9a0cfa..86b0b796f8 100644 --- a/pkg/controller/common/keystore/resources_test.go +++ b/pkg/controller/common/keystore/resources_test.go @@ -7,8 +7,8 @@ package keystore import ( "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" watches2 "github.com/elastic/cloud-on-k8s/pkg/controller/common/watches" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/name" @@ -40,35 +40,35 @@ var ( "key1": []byte("value1"), }, } - testSecureSettingsSecretRef = commonv1alpha1.SecretSource{ + testSecureSettingsSecretRef = commonv1beta1.SecretSource{ SecretName: testSecureSettingsSecretName, } - testKibana = v1alpha1.Kibana{ + testKibana = v1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "kibana", }, } - testKibanaWithSecureSettings = v1alpha1.Kibana{ + testKibanaWithSecureSettings = v1beta1.Kibana{ TypeMeta: metav1.TypeMeta{ Kind: "kibana", }, ObjectMeta: testKibana.ObjectMeta, - Spec: v1alpha1.KibanaSpec{ - SecureSettings: []commonv1alpha1.SecretSource{testSecureSettingsSecretRef}, + Spec: v1beta1.KibanaSpec{ + SecureSettings: []commonv1beta1.SecretSource{testSecureSettingsSecretRef}, }, } ) func TestResources(t *testing.T) { sc := scheme.Scheme - require.NoError(t, v1alpha1.SchemeBuilder.AddToScheme(sc)) + require.NoError(t, v1beta1.SchemeBuilder.AddToScheme(sc)) varFalse := false tests := []struct { name string client k8s.Client - kb v1alpha1.Kibana + kb v1beta1.Kibana wantNil bool wantContainers *corev1.Container wantVersion string diff --git a/pkg/controller/common/keystore/user_secret.go b/pkg/controller/common/keystore/user_secret.go index b8647db178..5bf4896533 100644 --- a/pkg/controller/common/keystore/user_secret.go +++ b/pkg/controller/common/keystore/user_secret.go @@ -9,7 +9,7 @@ import ( "reflect" "strings" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" "github.com/elastic/cloud-on-k8s/pkg/controller/common/finalizer" @@ -141,7 +141,7 @@ func retrieveUserSecrets(c k8s.Client, recorder record.EventRecorder, hasKeystor return userSecrets, nil } -func retrieveUserSecret(c k8s.Client, recorder record.EventRecorder, hasKeystore HasKeystore, secretSrc commonv1alpha1.SecretSource) (*corev1.Secret, bool, error) { +func retrieveUserSecret(c k8s.Client, recorder record.EventRecorder, hasKeystore HasKeystore, secretSrc commonv1beta1.SecretSource) (*corev1.Secret, bool, error) { namespace := hasKeystore.GetNamespace() secretName := secretSrc.SecretName @@ -206,7 +206,7 @@ func secureSettingsWatchName(namespacedName types.NamespacedName) string { // Only one watch per cluster is registered: // - if it already exists with a different secret, it is replaced to watch the new secret. // - if the given user secret is nil, the watch is removed. -func watchSecureSettings(watched watches.DynamicWatches, secureSettingsRef []commonv1alpha1.SecretSource, nn types.NamespacedName) error { +func watchSecureSettings(watched watches.DynamicWatches, secureSettingsRef []commonv1beta1.SecretSource, nn types.NamespacedName) error { watchName := secureSettingsWatchName(nn) if secureSettingsRef == nil { watched.Secrets.RemoveHandlerForKey(watchName) diff --git a/pkg/controller/common/keystore/user_secret_test.go b/pkg/controller/common/keystore/user_secret_test.go index 11d332f00d..8f251bb831 100644 --- a/pkg/controller/common/keystore/user_secret_test.go +++ b/pkg/controller/common/keystore/user_secret_test.go @@ -8,8 +8,8 @@ import ( "reflect" "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" "github.com/elastic/cloud-on-k8s/pkg/controller/common/volume" @@ -32,7 +32,7 @@ func Test_secureSettingsWatchName(t *testing.T) { func Test_secureSettingsVolume(t *testing.T) { s := scheme.Scheme - require.NoError(t, v1alpha1.AddToScheme(s)) + require.NoError(t, v1beta1.AddToScheme(s)) expectedSecretVolume := volume.NewSecretVolumeWithMountPath( "kibana-kb-secure-settings", @@ -53,7 +53,7 @@ func Test_secureSettingsVolume(t *testing.T) { name string c k8s.Client w watches.DynamicWatches - kb v1alpha1.Kibana + kb v1beta1.Kibana wantVolume *volume.SecretVolume wantVersion string wantWatches []string @@ -135,7 +135,7 @@ func Test_secureSettingsVolume(t *testing.T) { func Test_reconcileSecureSettings(t *testing.T) { true := true s := scheme.Scheme - require.NoError(t, v1alpha1.AddToScheme(s)) + require.NoError(t, v1beta1.AddToScheme(s)) type args struct { c k8s.Client @@ -143,7 +143,7 @@ func Test_reconcileSecureSettings(t *testing.T) { userSecrets []corev1.Secret namer name.Namer } - kibanaFixture := &v1alpha1.Kibana{ + kibanaFixture := &v1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Name: "kb", Namespace: "ns", @@ -154,7 +154,7 @@ func Test_reconcileSecureSettings(t *testing.T) { Namespace: "ns", OwnerReferences: []metav1.OwnerReference{ { - APIVersion: "kibana.k8s.elastic.co/v1alpha1", + APIVersion: "kibana.k8s.elastic.co/v1beta1", Kind: "Kibana", Name: "kb", UID: "", @@ -336,25 +336,25 @@ func Test_retrieveUserSecrets(t *testing.T) { "key3": []byte("value3"), }, } - testKibana := &v1alpha1.Kibana{ + testKibana := &v1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Name: "kb", Namespace: "ns", }, - Spec: v1alpha1.KibanaSpec{ - SecureSettings: []commonv1alpha1.SecretSource{}, + Spec: v1beta1.KibanaSpec{ + SecureSettings: []commonv1beta1.SecretSource{}, }, } tests := []struct { name string - args []commonv1alpha1.SecretSource + args []commonv1beta1.SecretSource want []corev1.Secret wantErr bool }{ { name: "secure settings secret with only secret name should be retrieved", - args: []commonv1alpha1.SecretSource{ + args: []commonv1beta1.SecretSource{ { SecretName: testSecretName, }, @@ -364,10 +364,10 @@ func Test_retrieveUserSecrets(t *testing.T) { }, { name: "secure settings secret with empty items should fail", - args: []commonv1alpha1.SecretSource{ + args: []commonv1beta1.SecretSource{ { SecretName: testSecretName, - Entries: []commonv1alpha1.KeyToPath{}, + Entries: []commonv1beta1.KeyToPath{}, }, }, want: nil, @@ -375,10 +375,10 @@ func Test_retrieveUserSecrets(t *testing.T) { }, { name: "secure settings secret with invalid key should fail", - args: []commonv1alpha1.SecretSource{ + args: []commonv1beta1.SecretSource{ { SecretName: testSecretName, - Entries: []commonv1alpha1.KeyToPath{ + Entries: []commonv1beta1.KeyToPath{ {Key: "unknown"}, }, }, @@ -388,10 +388,10 @@ func Test_retrieveUserSecrets(t *testing.T) { }, { name: "secure settings secret with valid key should be retrieved", - args: []commonv1alpha1.SecretSource{ + args: []commonv1beta1.SecretSource{ { SecretName: testSecretName, - Entries: []commonv1alpha1.KeyToPath{ + Entries: []commonv1beta1.KeyToPath{ {Key: "key2"}, }, }, @@ -409,10 +409,10 @@ func Test_retrieveUserSecrets(t *testing.T) { }, { name: "secure settings secret with valid key and path should be retrieved", - args: []commonv1alpha1.SecretSource{ + args: []commonv1beta1.SecretSource{ { SecretName: testSecretName, - Entries: []commonv1alpha1.KeyToPath{ + Entries: []commonv1beta1.KeyToPath{ {Key: "key1"}, {Key: "key3", Path: "newKey"}, }, diff --git a/pkg/controller/common/license/check_test.go b/pkg/controller/common/license/check_test.go index d1ea95ce66..5c75029372 100644 --- a/pkg/controller/common/license/check_test.go +++ b/pkg/controller/common/license/check_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/chrono" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/require" @@ -19,7 +19,7 @@ import ( ) func TestChecker_EnterpriseFeaturesEnabled(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) privKey, err := x509.ParsePKCS1PrivateKey(privateKeyFixture) require.NoError(t, err) diff --git a/pkg/controller/common/license/trial_test.go b/pkg/controller/common/license/trial_test.go index 0ed603ae24..0be0ddbc82 100644 --- a/pkg/controller/common/license/trial_test.go +++ b/pkg/controller/common/license/trial_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/pkg/errors" diff --git a/pkg/controller/common/scheme/scheme.go b/pkg/controller/common/scheme/scheme.go index a4853fbbde..d29ea30c1c 100644 --- a/pkg/controller/common/scheme/scheme.go +++ b/pkg/controller/common/scheme/scheme.go @@ -5,10 +5,10 @@ package scheme import ( - apmv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - esv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + apmv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + esv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ) @@ -19,18 +19,18 @@ func SetupScheme() error { if err != nil { return err } - err = apmv1alpha1.AddToScheme(clientgoscheme.Scheme) + err = apmv1beta1.AddToScheme(clientgoscheme.Scheme) if err != nil { return err } - err = commonv1alpha1.AddToScheme(clientgoscheme.Scheme) + err = commonv1beta1.AddToScheme(clientgoscheme.Scheme) if err != nil { return err } - err = esv1alpha1.AddToScheme(clientgoscheme.Scheme) + err = esv1beta1.AddToScheme(clientgoscheme.Scheme) if err != nil { return err } - err = kbv1alpha1.AddToScheme(clientgoscheme.Scheme) + err = kbv1beta1.AddToScheme(clientgoscheme.Scheme) return err } diff --git a/pkg/controller/common/user/label.go b/pkg/controller/common/user/label.go index f274f19630..169dcf054f 100644 --- a/pkg/controller/common/user/label.go +++ b/pkg/controller/common/user/label.go @@ -5,7 +5,7 @@ package user import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -22,7 +22,7 @@ const ( // NewLabelSelectorForElasticsearch returns a labels.Selector that matches the labels as constructed by // NewLabels for the provided cluster name and of for a resource of type "user" -func NewLabelSelectorForElasticsearch(es v1alpha1.Elasticsearch) client.MatchingLabels { +func NewLabelSelectorForElasticsearch(es v1beta1.Elasticsearch) client.MatchingLabels { return client.MatchingLabels(NewLabels(k8s.ExtractNamespacedName(&es))) } diff --git a/pkg/controller/elasticsearch/certificates/ca_reconcile.go b/pkg/controller/elasticsearch/certificates/ca_reconcile.go index e1dff9612a..f7671ec54f 100644 --- a/pkg/controller/elasticsearch/certificates/ca_reconcile.go +++ b/pkg/controller/elasticsearch/certificates/ca_reconcile.go @@ -8,7 +8,7 @@ import ( "crypto/x509" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" @@ -35,7 +35,7 @@ type CertificateResources struct { // reconcileGenericResources reconciles the expected generic resources of a cluster. func Reconcile( driver driver.Interface, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, services []corev1.Service, caRotation certificates.RotationParams, certRotation certificates.RotationParams, diff --git a/pkg/controller/elasticsearch/certificates/transport/csr.go b/pkg/controller/elasticsearch/certificates/transport/csr.go index 1f23e2e5d3..46390ce16f 100644 --- a/pkg/controller/elasticsearch/certificates/transport/csr.go +++ b/pkg/controller/elasticsearch/certificates/transport/csr.go @@ -11,7 +11,7 @@ import ( "net" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" netutil "github.com/elastic/cloud-on-k8s/pkg/utils/net" "github.com/pkg/errors" @@ -21,7 +21,7 @@ import ( // createValidatedCertificateTemplate validates a CSR and creates a certificate template. func createValidatedCertificateTemplate( pod corev1.Pod, - cluster v1alpha1.Elasticsearch, + cluster v1beta1.Elasticsearch, csr *x509.CertificateRequest, certValidity time.Duration, ) (*certificates.ValidatedCertificateTemplate, error) { @@ -62,7 +62,7 @@ func createValidatedCertificateTemplate( } func buildGeneralNames( - cluster v1alpha1.Elasticsearch, + cluster v1beta1.Elasticsearch, pod corev1.Pod, ) ([]certificates.GeneralName, error) { podIP := net.ParseIP(pod.Status.PodIP) diff --git a/pkg/controller/elasticsearch/certificates/transport/csr_test.go b/pkg/controller/elasticsearch/certificates/transport/csr_test.go index 88bed623db..f3a35b82b3 100644 --- a/pkg/controller/elasticsearch/certificates/transport/csr_test.go +++ b/pkg/controller/elasticsearch/certificates/transport/csr_test.go @@ -9,7 +9,7 @@ import ( "net" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -73,7 +73,7 @@ func Test_buildGeneralNames(t *testing.T) { require.NoError(t, err) type args struct { - cluster v1alpha1.Elasticsearch + cluster v1beta1.Elasticsearch pod corev1.Pod } tests := []struct { diff --git a/pkg/controller/elasticsearch/certificates/transport/pod_secret.go b/pkg/controller/elasticsearch/certificates/transport/pod_secret.go index 83a1032682..ddaa72583f 100644 --- a/pkg/controller/elasticsearch/certificates/transport/pod_secret.go +++ b/pkg/controller/elasticsearch/certificates/transport/pod_secret.go @@ -13,7 +13,7 @@ import ( "reflect" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" corev1 "k8s.io/api/core/v1" ) @@ -31,7 +31,7 @@ func PodCertFileName(podName string) string { // ensureTransportCertificatesSecretContentsForPod ensures that the transport certificates secret has the correct // content for a specific pod func ensureTransportCertificatesSecretContentsForPod( - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, secret *corev1.Secret, pod corev1.Pod, ca *certificates.CA, @@ -107,7 +107,7 @@ func ensureTransportCertificatesSecretContentsForPod( // - certificate has no SAN extra extension // - certificate SAN and IP does not match pod SAN and IP func shouldIssueNewCertificate( - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, secret corev1.Secret, pod corev1.Pod, privateKey *rsa.PrivateKey, diff --git a/pkg/controller/elasticsearch/certificates/transport/public_secret.go b/pkg/controller/elasticsearch/certificates/transport/public_secret.go index e8f82666bf..9ce5e54e09 100644 --- a/pkg/controller/elasticsearch/certificates/transport/public_secret.go +++ b/pkg/controller/elasticsearch/certificates/transport/public_secret.go @@ -7,7 +7,7 @@ package transport import ( "reflect" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" @@ -24,7 +24,7 @@ import ( func ReconcileTransportCertsPublicSecret( c k8s.Client, scheme *runtime.Scheme, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, ca *certificates.CA, ) error { esNSN := k8s.ExtractNamespacedName(&es) diff --git a/pkg/controller/elasticsearch/certificates/transport/public_secret_test.go b/pkg/controller/elasticsearch/certificates/transport/public_secret_test.go index 2d9b0ba5b1..40932e0cfb 100644 --- a/pkg/controller/elasticsearch/certificates/transport/public_secret_test.go +++ b/pkg/controller/elasticsearch/certificates/transport/public_secret_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -28,7 +28,7 @@ import ( ) func TestReconcileTransportCertsPublicSecret(t *testing.T) { - owner := &v1alpha1.Elasticsearch{ + owner := &v1beta1.Elasticsearch{ ObjectMeta: v1.ObjectMeta{Name: "test-es-name", Namespace: "test-namespace"}, } diff --git a/pkg/controller/elasticsearch/certificates/transport/reconcile.go b/pkg/controller/elasticsearch/certificates/transport/reconcile.go index 79ceed4d58..4b35a33af8 100644 --- a/pkg/controller/elasticsearch/certificates/transport/reconcile.go +++ b/pkg/controller/elasticsearch/certificates/transport/reconcile.go @@ -9,7 +9,7 @@ import ( "reflect" "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" @@ -32,7 +32,7 @@ func ReconcileTransportCertificatesSecrets( c k8s.Client, scheme *runtime.Scheme, ca *certificates.CA, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, rotationParams certificates.RotationParams, ) (reconcile.Result, error) { var pods corev1.PodList @@ -111,7 +111,7 @@ func ReconcileTransportCertificatesSecrets( func ensureTransportCertificatesSecretExists( c k8s.Client, scheme *runtime.Scheme, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, ) (*corev1.Secret, error) { expected := corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/controller/elasticsearch/certificates/transport/reconcile_test.go b/pkg/controller/elasticsearch/certificates/transport/reconcile_test.go index 3e05297cce..6efd9d93f5 100644 --- a/pkg/controller/elasticsearch/certificates/transport/reconcile_test.go +++ b/pkg/controller/elasticsearch/certificates/transport/reconcile_test.go @@ -9,7 +9,7 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/assert" @@ -42,7 +42,7 @@ func Test_ensureTransportCertificateSecretExists(t *testing.T) { type args struct { c k8s.Client scheme *runtime.Scheme - owner v1alpha1.Elasticsearch + owner v1beta1.Elasticsearch } tests := []struct { name string diff --git a/pkg/controller/elasticsearch/certificates/transport/transport_fixtures_test.go b/pkg/controller/elasticsearch/certificates/transport/transport_fixtures_test.go index d09fae1f7f..b844d03508 100644 --- a/pkg/controller/elasticsearch/certificates/transport/transport_fixtures_test.go +++ b/pkg/controller/elasticsearch/certificates/transport/transport_fixtures_test.go @@ -11,7 +11,7 @@ import ( "crypto/x509/pkix" "encoding/pem" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -28,7 +28,7 @@ var ( certData []byte pemCert []byte testIP = "1.2.3.4" - testES = v1alpha1.Elasticsearch{ + testES = v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{Name: "test-es-name", Namespace: "test-namespace"}, } testPod = corev1.Pod{ @@ -62,7 +62,7 @@ wg/HcAJWY60xZTJDFN+Qfx8ZQvBEin6c2/h+zZi5IVY= ) func init() { - if err := v1alpha1.AddToScheme(scheme.Scheme); err != nil { + if err := v1beta1.AddToScheme(scheme.Scheme); err != nil { panic(err) } diff --git a/pkg/controller/elasticsearch/cleanup/resources.go b/pkg/controller/elasticsearch/cleanup/resources.go index 0b0b5d3d23..7b51170e63 100644 --- a/pkg/controller/elasticsearch/cleanup/resources.go +++ b/pkg/controller/elasticsearch/cleanup/resources.go @@ -7,7 +7,7 @@ package cleanup import ( "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" corev1 "k8s.io/api/core/v1" @@ -35,7 +35,7 @@ func IsTooYoungForGC(object metav1.Object) bool { } // DeleteOrphanedSecrets cleans up secrets that are not needed anymore for the given es cluster. -func DeleteOrphanedSecrets(c k8s.Client, es v1alpha1.Elasticsearch) error { +func DeleteOrphanedSecrets(c k8s.Client, es v1beta1.Elasticsearch) error { var secrets corev1.SecretList ns := client.InNamespace(es.Namespace) matchLabels := label.NewLabelSelectorForElasticsearch(es) diff --git a/pkg/controller/elasticsearch/cleanup/resources_test.go b/pkg/controller/elasticsearch/cleanup/resources_test.go index d24fc65d24..64508c318f 100644 --- a/pkg/controller/elasticsearch/cleanup/resources_test.go +++ b/pkg/controller/elasticsearch/cleanup/resources_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/require" @@ -69,12 +69,12 @@ func secret(name string, clusterName string, podRef string, creationTime time.Ti } func TestDeleteOrphanedSecrets(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) now := time.Now() whileAgo := time.Now().Add(-DeleteAfter).Add(-1 * time.Minute) - es := v1alpha1.Elasticsearch{ + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns1", Name: "es1", @@ -93,7 +93,7 @@ func TestDeleteOrphanedSecrets(t *testing.T) { tests := []struct { name string client k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch secretsAfterCleanup []*corev1.Secret }{ { diff --git a/pkg/controller/elasticsearch/configmap/configmap.go b/pkg/controller/elasticsearch/configmap/configmap.go index c7f7f8ab38..a70aadd107 100644 --- a/pkg/controller/elasticsearch/configmap/configmap.go +++ b/pkg/controller/elasticsearch/configmap/configmap.go @@ -5,7 +5,7 @@ package configmap import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/initcontainer" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" @@ -31,7 +31,7 @@ func NewConfigMapWithData(es types.NamespacedName, data map[string]string) corev // ReconcileScriptsConfigMap reconciles a configmap containing scripts used by // init containers and readiness probe. -func ReconcileScriptsConfigMap(c k8s.Client, scheme *runtime.Scheme, es v1alpha1.Elasticsearch) error { +func ReconcileScriptsConfigMap(c k8s.Client, scheme *runtime.Scheme, es v1beta1.Elasticsearch) error { fsScript, err := initcontainer.RenderPrepareFsScript() if err != nil { return err diff --git a/pkg/controller/elasticsearch/configmap/configmap_control.go b/pkg/controller/elasticsearch/configmap/configmap_control.go index 3d7c115730..4faff37037 100644 --- a/pkg/controller/elasticsearch/configmap/configmap_control.go +++ b/pkg/controller/elasticsearch/configmap/configmap_control.go @@ -7,7 +7,7 @@ package configmap import ( "reflect" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" corev1 "k8s.io/api/core/v1" @@ -18,7 +18,7 @@ import ( func ReconcileConfigMap( c k8s.Client, scheme *runtime.Scheme, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, expected corev1.ConfigMap, ) error { reconciled := &corev1.ConfigMap{} diff --git a/pkg/controller/elasticsearch/driver/bootstrap.go b/pkg/controller/elasticsearch/driver/bootstrap.go index f4138ed8c5..bdcced6bbb 100644 --- a/pkg/controller/elasticsearch/driver/bootstrap.go +++ b/pkg/controller/elasticsearch/driver/bootstrap.go @@ -5,7 +5,7 @@ package driver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/observer" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/version/zen2" @@ -18,12 +18,12 @@ const ( ) // AnnotatedForBootstrap returns true if the cluster has been annotated with the UUID already. -func AnnotatedForBootstrap(cluster v1alpha1.Elasticsearch) bool { +func AnnotatedForBootstrap(cluster v1beta1.Elasticsearch) bool { _, bootstrapped := cluster.Annotations[ClusterUUIDAnnotationName] return bootstrapped } -func ReconcileClusterUUID(c k8s.Client, cluster *v1alpha1.Elasticsearch, observedState observer.State) error { +func ReconcileClusterUUID(c k8s.Client, cluster *v1beta1.Elasticsearch, observedState observer.State) error { reBootstrap, err := clusterNeedsReBootstrap(c, cluster) if err != nil { return err @@ -49,7 +49,7 @@ func ReconcileClusterUUID(c k8s.Client, cluster *v1alpha1.Elasticsearch, observe return nil } -func removeUUIDAnnotation(client k8s.Client, es *v1alpha1.Elasticsearch) error { +func removeUUIDAnnotation(client k8s.Client, es *v1beta1.Elasticsearch) error { annotations := es.Annotations if annotations == nil { return nil @@ -61,7 +61,7 @@ func removeUUIDAnnotation(client k8s.Client, es *v1alpha1.Elasticsearch) error { // clusterNeedsReBootstrap is true if we are updating a single master cluster from 6.x to 7.x // because we lose the 'cluster' when rolling the single master node. // Invariant: no grow and shrink -func clusterNeedsReBootstrap(client k8s.Client, es *v1alpha1.Elasticsearch) (bool, error) { +func clusterNeedsReBootstrap(client k8s.Client, es *v1beta1.Elasticsearch) (bool, error) { initialZen2Upgrade, err := zen2.IsInitialZen2Upgrade(client, *es) if err != nil { return false, err @@ -79,7 +79,7 @@ func clusterIsBootstrapped(observedState observer.State) bool { } // annotateWithUUID annotates the cluster with its UUID, to mark it as "bootstrapped". -func annotateWithUUID(cluster *v1alpha1.Elasticsearch, observedState observer.State, c k8s.Client) error { +func annotateWithUUID(cluster *v1beta1.Elasticsearch, observedState observer.State, c k8s.Client) error { log.Info("Annotating bootstrapped cluster with its UUID", "namespace", cluster.Namespace, "es_name", cluster.Name) if cluster.Annotations == nil { cluster.Annotations = make(map[string]string) diff --git a/pkg/controller/elasticsearch/driver/bootstrap_test.go b/pkg/controller/elasticsearch/driver/bootstrap_test.go index 8089a23e02..9b45fb3e1f 100644 --- a/pkg/controller/elasticsearch/driver/bootstrap_test.go +++ b/pkg/controller/elasticsearch/driver/bootstrap_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/observer" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -20,30 +20,30 @@ import ( "k8s.io/client-go/kubernetes/scheme" ) -func bootstrappedES() *v1alpha1.Elasticsearch { - return &v1alpha1.Elasticsearch{ +func bootstrappedES() *v1beta1.Elasticsearch { + return &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "cluster", Annotations: map[string]string{ClusterUUIDAnnotationName: "uuid"}, }, - Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}, + Spec: v1beta1.ElasticsearchSpec{Version: "7.3.0"}, } } -func notBootstrappedES() *v1alpha1.Elasticsearch { - return &v1alpha1.Elasticsearch{ +func notBootstrappedES() *v1beta1.Elasticsearch { + return &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{Name: "cluster"}, - Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}, + Spec: v1beta1.ElasticsearchSpec{Version: "7.3.0"}, } } -func reBootstrappingES() *v1alpha1.Elasticsearch { - return &v1alpha1.Elasticsearch{ +func reBootstrappingES() *v1beta1.Elasticsearch { + return &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "cluster", Annotations: map[string]string{}, }, - Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}, + Spec: v1beta1.ElasticsearchSpec{Version: "7.3.0"}, } } @@ -53,7 +53,7 @@ func TestAnnotatedForBootstrap(t *testing.T) { } func Test_annotateWithUUID(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) cluster := notBootstrappedES() observedState := observer.State{ClusterInfo: &client.Info{ClusterUUID: "cluster-uuid"}} @@ -63,20 +63,20 @@ func Test_annotateWithUUID(t *testing.T) { require.NoError(t, err) require.True(t, AnnotatedForBootstrap(*cluster)) - var retrieved v1alpha1.Elasticsearch + var retrieved v1beta1.Elasticsearch err = k8sClient.Get(k8s.ExtractNamespacedName(cluster), &retrieved) require.NoError(t, err) require.True(t, AnnotatedForBootstrap(retrieved)) } func TestReconcileClusterUUID(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) tests := []struct { name string c k8s.Client - cluster *v1alpha1.Elasticsearch + cluster *v1beta1.Elasticsearch observedState observer.State - wantCluster *v1alpha1.Elasticsearch + wantCluster *v1beta1.Elasticsearch }{ { name: "already annotated", diff --git a/pkg/controller/elasticsearch/driver/downscale.go b/pkg/controller/elasticsearch/driver/downscale.go index cc60511a3d..6d6e3a02ba 100644 --- a/pkg/controller/elasticsearch/driver/downscale.go +++ b/pkg/controller/elasticsearch/driver/downscale.go @@ -5,7 +5,7 @@ package driver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" @@ -124,7 +124,7 @@ func attemptDownscale( // removeStatefulSetResources deletes the given StatefulSet along with the corresponding // headless service and configuration secret. -func removeStatefulSetResources(k8sClient k8s.Client, es v1alpha1.Elasticsearch, statefulSet appsv1.StatefulSet) error { +func removeStatefulSetResources(k8sClient k8s.Client, es v1beta1.Elasticsearch, statefulSet appsv1.StatefulSet) error { headlessSvc := nodespec.HeadlessService(k8s.ExtractNamespacedName(&es), statefulSet.Name) err := k8sClient.Delete(&headlessSvc) if err != nil && !apierrors.IsNotFound(err) { @@ -216,7 +216,7 @@ func doDownscale(downscaleCtx downscaleContext, downscale ssetDownscale, actualS func updateZenSettingsForDownscale( c k8s.Client, esClient esclient.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, reconcileState *reconcile.State, actualStatefulSets sset.StatefulSetList, excludeNodes ...string, @@ -237,7 +237,7 @@ func updateZenSettingsForDownscale( func maybeUpdateZen1ForDownscale( c k8s.Client, esClient esclient.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, reconcileState *reconcile.State, actualStatefulSets sset.StatefulSetList) error { // Check if we have at least one Zen1 compatible pod or StatefulSet in flight. diff --git a/pkg/controller/elasticsearch/driver/downscale_invariants.go b/pkg/controller/elasticsearch/driver/downscale_invariants.go index 7d7a8eeebf..847845f024 100644 --- a/pkg/controller/elasticsearch/driver/downscale_invariants.go +++ b/pkg/controller/elasticsearch/driver/downscale_invariants.go @@ -5,7 +5,7 @@ package driver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/reconcile" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" @@ -43,7 +43,7 @@ type downscaleState struct { } // newDownscaleState creates a new downscaleState. -func newDownscaleState(c k8s.Client, es v1alpha1.Elasticsearch) (*downscaleState, error) { +func newDownscaleState(c k8s.Client, es v1beta1.Elasticsearch) (*downscaleState, error) { // retrieve the number of masters running ready actualPods, err := sset.GetActualPodsForCluster(c, es) if err != nil { diff --git a/pkg/controller/elasticsearch/driver/downscale_invariants_test.go b/pkg/controller/elasticsearch/driver/downscale_invariants_test.go index 89e0fc286e..ec29666052 100644 --- a/pkg/controller/elasticsearch/driver/downscale_invariants_test.go +++ b/pkg/controller/elasticsearch/driver/downscale_invariants_test.go @@ -15,13 +15,13 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) func Test_newDownscaleState(t *testing.T) { - es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: ssetMaster3Replicas.Namespace, Name: "name"}} + es := v1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: ssetMaster3Replicas.Namespace, Name: "name"}} tests := []struct { name string initialResources []runtime.Object diff --git a/pkg/controller/elasticsearch/driver/downscale_test.go b/pkg/controller/elasticsearch/driver/downscale_test.go index 885e786895..00caf12b29 100644 --- a/pkg/controller/elasticsearch/driver/downscale_test.go +++ b/pkg/controller/elasticsearch/driver/downscale_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" @@ -133,7 +133,7 @@ func TestHandleDownscale(t *testing.T) { downscaleCtx := downscaleContext{ k8sClient: k8sClient, expectations: expectations.NewExpectations(), - reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), + reconcileState: reconcile.NewState(v1beta1.Elasticsearch{}), shardLister: migration.NewFakeShardLister( esclient.Shards{ {Index: "index-1", Shard: "0", State: esclient.STARTED, NodeName: "ssetData4Replicas-2"}, @@ -141,7 +141,7 @@ func TestHandleDownscale(t *testing.T) { ), allocationSetter: esclient.NewAllocationSetter(esClient), esClient: esClient, - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "ns", @@ -599,7 +599,7 @@ func Test_attemptDownscale(t *testing.T) { downscaleCtx := downscaleContext{ k8sClient: k8sClient, expectations: expectations.NewExpectations(), - reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), + reconcileState: reconcile.NewState(v1beta1.Elasticsearch{}), shardLister: migration.NewFakeShardLister(esclient.Shards{}), esClient: &fakeESClient{}, } @@ -707,7 +707,7 @@ func Test_doDownscale_zen2VotingConfigExclusions(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - es := v1alpha1.Elasticsearch{ + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: ssetMasters.Namespace, Name: "es", @@ -730,7 +730,7 @@ func Test_doDownscale_zen2VotingConfigExclusions(t *testing.T) { downscaleCtx := downscaleContext{ k8sClient: k8sClient, expectations: expectations.NewExpectations(), - reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), + reconcileState: reconcile.NewState(v1beta1.Elasticsearch{}), esClient: esClient, es: es, } @@ -748,7 +748,7 @@ func Test_doDownscale_zen2VotingConfigExclusions(t *testing.T) { func Test_doDownscale_zen1MinimumMasterNodes(t *testing.T) { require.NoError(t, commonscheme.SetupScheme()) - es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: ssetMaster3Replicas.Namespace, Name: "es"}} + es := v1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: ssetMaster3Replicas.Namespace, Name: "es"}} ssetMasters := sset.TestSset{Name: "masters", Version: "6.8.0", Replicas: 3, Master: true, Data: false}.Build() masterPods := []corev1.Pod{ sset.TestPod{ @@ -828,7 +828,7 @@ func Test_doDownscale_zen1MinimumMasterNodes(t *testing.T) { downscaleCtx := downscaleContext{ k8sClient: k8sClient, expectations: expectations.NewExpectations(), - reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), + reconcileState: reconcile.NewState(v1beta1.Elasticsearch{}), esClient: esClient, es: es, } @@ -845,12 +845,12 @@ func Test_doDownscale_zen1MinimumMasterNodes(t *testing.T) { } func Test_removeStatefulSetResources(t *testing.T) { - es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "cluster"}} + es := v1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "cluster"}} sset := sset.TestSset{Namespace: "ns", Name: "sset", ClusterName: es.Name}.Build() cfg := settings.ConfigSecret(es, sset.Name, []byte("fake config data")) svc := nodespec.HeadlessService(k8s.ExtractNamespacedName(&es), sset.Name) - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) tests := []struct { name string resources []runtime.Object diff --git a/pkg/controller/elasticsearch/driver/downscale_utils.go b/pkg/controller/elasticsearch/driver/downscale_utils.go index 1c8f106490..9e96488165 100644 --- a/pkg/controller/elasticsearch/driver/downscale_utils.go +++ b/pkg/controller/elasticsearch/driver/downscale_utils.go @@ -5,7 +5,7 @@ package driver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/observer" @@ -29,7 +29,7 @@ type downscaleContext struct { reconcileState *reconcile.State expectations *expectations.Expectations // ES cluster - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch } func newDownscaleContext( @@ -40,7 +40,7 @@ func newDownscaleContext( reconcileState *reconcile.State, expectations *expectations.Expectations, // ES cluster - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, ) downscaleContext { return downscaleContext{ k8sClient: k8sClient, diff --git a/pkg/controller/elasticsearch/driver/driver.go b/pkg/controller/elasticsearch/driver/driver.go index 28157b9b2f..4801db97d3 100644 --- a/pkg/controller/elasticsearch/driver/driver.go +++ b/pkg/controller/elasticsearch/driver/driver.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" commondriver "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" @@ -62,7 +62,7 @@ type DefaultDriverParameters struct { OperatorParameters operator.Parameters // ES is the Elasticsearch resource to reconcile - ES v1alpha1.Elasticsearch + ES v1beta1.Elasticsearch // SupportedVersions verifies whether we can support upgrading from the current pods. SupportedVersions esversion.LowestHighestSupportedVersions diff --git a/pkg/controller/elasticsearch/driver/esstate.go b/pkg/controller/elasticsearch/driver/esstate.go index efe96f2c05..2a24a27f02 100644 --- a/pkg/controller/elasticsearch/driver/esstate.go +++ b/pkg/controller/elasticsearch/driver/esstate.go @@ -8,7 +8,7 @@ import ( "context" "sync" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/utils/stringsutil" ) @@ -126,7 +126,7 @@ func (h *memoizingGreenHealth) initialize() error { if err != nil { return err } - h.greenHealth = health.Status == string(v1alpha1.ElasticsearchGreenHealth) + h.greenHealth = health.Status == string(v1beta1.ElasticsearchGreenHealth) return nil } diff --git a/pkg/controller/elasticsearch/driver/esstate_test.go b/pkg/controller/elasticsearch/driver/esstate_test.go index 04d8d9387b..6371042be2 100644 --- a/pkg/controller/elasticsearch/driver/esstate_test.go +++ b/pkg/controller/elasticsearch/driver/esstate_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" ) @@ -153,7 +153,7 @@ func Test_memoizingShardsAllocationEnabled_ShardAllocationsEnabled(t *testing.T) } func Test_memoizingGreenHealth_GreenHealth(t *testing.T) { - esClient := &fakeESClient{health: esclient.Health{Status: string(v1alpha1.ElasticsearchGreenHealth)}} + esClient := &fakeESClient{health: esclient.Health{Status: string(v1beta1.ElasticsearchGreenHealth)}} h := &memoizingGreenHealth{esClient: esClient} green, err := h.GreenHealth() @@ -168,7 +168,7 @@ func Test_memoizingGreenHealth_GreenHealth(t *testing.T) { require.True(t, green) // simulate yellow health - esClient = &fakeESClient{health: esclient.Health{Status: string(v1alpha1.ElasticsearchYellowHealth)}} + esClient = &fakeESClient{health: esclient.Health{Status: string(v1beta1.ElasticsearchYellowHealth)}} h = &memoizingGreenHealth{esClient: esClient} green, err = h.GreenHealth() require.NoError(t, err) diff --git a/pkg/controller/elasticsearch/driver/fixtures.go b/pkg/controller/elasticsearch/driver/fixtures.go index 9199b869f1..80c4f4a5d6 100644 --- a/pkg/controller/elasticsearch/driver/fixtures.go +++ b/pkg/controller/elasticsearch/driver/fixtures.go @@ -5,7 +5,7 @@ package driver import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -103,15 +103,15 @@ func newUpgradeTestPods(pods ...testPod) upgradeTestPods { return result } -func (u upgradeTestPods) toES(maxUnavailable int) v1alpha1.Elasticsearch { - return v1alpha1.Elasticsearch{ +func (u upgradeTestPods) toES(maxUnavailable int) v1beta1.Elasticsearch { + return v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: TestEsName, Namespace: TestEsNamespace, }, - Spec: v1alpha1.ElasticsearchSpec{ - UpdateStrategy: v1alpha1.UpdateStrategy{ - ChangeBudget: &v1alpha1.ChangeBudget{ + Spec: v1beta1.ElasticsearchSpec{ + UpdateStrategy: v1beta1.UpdateStrategy{ + ChangeBudget: &v1beta1.ChangeBudget{ MaxUnavailable: maxUnavailable, }, }, diff --git a/pkg/controller/elasticsearch/driver/pvc.go b/pkg/controller/elasticsearch/driver/pvc.go index 22a86f4bde..efc17733d7 100644 --- a/pkg/controller/elasticsearch/driver/pvc.go +++ b/pkg/controller/elasticsearch/driver/pvc.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -24,7 +24,7 @@ import ( // * leftover PVCs created for StatefulSets replicas that don't exist anymore (eg. downscale from 5 to 3 nodes) func GarbageCollectPVCs( k8sClient k8s.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, actualStatefulSets sset.StatefulSetList, expectedStatefulSets sset.StatefulSetList, ) error { diff --git a/pkg/controller/elasticsearch/driver/pvc_test.go b/pkg/controller/elasticsearch/driver/pvc_test.go index 72aec30d39..a280001bef 100644 --- a/pkg/controller/elasticsearch/driver/pvc_test.go +++ b/pkg/controller/elasticsearch/driver/pvc_test.go @@ -15,7 +15,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -134,7 +134,7 @@ func Test_pvcsToRemove(t *testing.T) { func TestGarbageCollectPVCs(t *testing.T) { // Test_pvcsToRemove covers most of the testing logic, // let's just check everything is correctly plugged to the k8s api here. - es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "es"}} + es := v1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "es"}} existingPVCS := []runtime.Object{ buildPVCPtr("claim1-sset1-0"), // should not be removed buildPVCPtr("claim1-oldsset-0"), // should be removed diff --git a/pkg/controller/elasticsearch/driver/upgrade.go b/pkg/controller/elasticsearch/driver/upgrade.go index 748187f223..e9d615e311 100644 --- a/pkg/controller/elasticsearch/driver/upgrade.go +++ b/pkg/controller/elasticsearch/driver/upgrade.go @@ -7,7 +7,7 @@ package driver import ( "context" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" @@ -88,7 +88,7 @@ func (d *defaultDriver) handleRollingUpgrades( type rollingUpgradeCtx struct { client k8s.Client - ES v1alpha1.Elasticsearch + ES v1beta1.Elasticsearch statefulSets sset.StatefulSetList esClient esclient.Client shardLister esclient.ShardLister @@ -217,7 +217,7 @@ func disableShardsAllocation(esClient esclient.Client) error { return esClient.DisableReplicaShardsAllocation(ctx) } -func doSyncFlush(es v1alpha1.Elasticsearch, esClient esclient.Client) error { +func doSyncFlush(es v1beta1.Elasticsearch, esClient esclient.Client) error { ctx, cancel := context.WithTimeout(context.Background(), esclient.DefaultReqTimeout) defer cancel() err := esClient.SyncedFlush(ctx) diff --git a/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go b/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go index 850fd4c747..07fb57a77d 100644 --- a/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go +++ b/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go @@ -7,7 +7,7 @@ package driver import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/migration" @@ -21,7 +21,7 @@ import ( func TestUpgradePodsDeletion_WithNodeTypeMutations(t *testing.T) { type fields struct { upgradeTestPods upgradeTestPods - ES v1alpha1.Elasticsearch + ES v1beta1.Elasticsearch green bool mutation mutation maxUnavailable int @@ -141,7 +141,7 @@ func TestUpgradePodsDeletion_WithNodeTypeMutations(t *testing.T) { shardLister: migration.NewFakeShardLister(client.Shards{}), esState: esState, expectations: expectations.NewExpectations(), - reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), + reconcileState: reconcile.NewState(v1beta1.Elasticsearch{}), expectedMasters: tt.fields.upgradeTestPods.toMasters(tt.fields.mutation), actualMasters: tt.fields.upgradeTestPods.toMasterPods(), podsToUpgrade: tt.fields.upgradeTestPods.toUpgrade(), @@ -168,7 +168,7 @@ func TestUpgradePodsDeletion_Delete(t *testing.T) { type fields struct { upgradeTestPods upgradeTestPods shardLister client.ShardLister - ES v1alpha1.Elasticsearch + ES v1beta1.Elasticsearch green bool maxUnavailable int podFilter filter diff --git a/pkg/controller/elasticsearch/driver/upscale.go b/pkg/controller/elasticsearch/driver/upscale.go index 64e07a1d7a..6026e94fbc 100644 --- a/pkg/controller/elasticsearch/driver/upscale.go +++ b/pkg/controller/elasticsearch/driver/upscale.go @@ -8,7 +8,7 @@ import ( appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/nodespec" @@ -22,7 +22,7 @@ import ( type upscaleCtx struct { k8sClient k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch scheme *runtime.Scheme observedState observer.State esState ESState @@ -88,7 +88,7 @@ func adjustResources( return adjustedResources, nil } -func adjustZenConfig(k8sClient k8s.Client, es v1alpha1.Elasticsearch, resources nodespec.ResourcesList) error { +func adjustZenConfig(k8sClient k8s.Client, es v1beta1.Elasticsearch, resources nodespec.ResourcesList) error { // patch configs to consider zen1 minimum master nodes if err := zen1.SetupMinimumMasterNodesConfig(k8sClient, es, resources); err != nil { return err diff --git a/pkg/controller/elasticsearch/driver/upscale_state.go b/pkg/controller/elasticsearch/driver/upscale_state.go index 326e824b7e..963497fcb7 100644 --- a/pkg/controller/elasticsearch/driver/upscale_state.go +++ b/pkg/controller/elasticsearch/driver/upscale_state.go @@ -10,7 +10,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/nodespec" @@ -23,7 +23,7 @@ type upscaleStateBuilder struct { upscaleState *upscaleState } -func (o *upscaleStateBuilder) InitOnce(c k8s.Client, es v1alpha1.Elasticsearch, esState ESState) (*upscaleState, error) { +func (o *upscaleStateBuilder) InitOnce(c k8s.Client, es v1beta1.Elasticsearch, esState ESState) (*upscaleState, error) { if o.once == nil { o.once = &sync.Once{} } @@ -39,7 +39,7 @@ type upscaleState struct { allowMasterCreation bool } -func newUpscaleState(c k8s.Client, es v1alpha1.Elasticsearch, esState ESState) (*upscaleState, error) { +func newUpscaleState(c k8s.Client, es v1beta1.Elasticsearch, esState ESState) (*upscaleState, error) { state := &upscaleState{ isBootstrapped: AnnotatedForBootstrap(es), allowMasterCreation: true, diff --git a/pkg/controller/elasticsearch/driver/upscale_state_test.go b/pkg/controller/elasticsearch/driver/upscale_state_test.go index 8aaed69642..cfb62d60e5 100644 --- a/pkg/controller/elasticsearch/driver/upscale_state_test.go +++ b/pkg/controller/elasticsearch/driver/upscale_state_test.go @@ -10,7 +10,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -204,7 +204,7 @@ func Test_isMasterNodeJoining(t *testing.T) { func Test_newUpscaleState(t *testing.T) { type args struct { c k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch esState ESState } tests := []struct { diff --git a/pkg/controller/elasticsearch/driver/upscale_test.go b/pkg/controller/elasticsearch/driver/upscale_test.go index 62439a5c6b..826fcddf46 100644 --- a/pkg/controller/elasticsearch/driver/upscale_test.go +++ b/pkg/controller/elasticsearch/driver/upscale_test.go @@ -8,7 +8,7 @@ import ( "sync" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" @@ -35,9 +35,9 @@ func init() { } func TestHandleUpscaleAndSpecChanges(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) k8sClient := k8s.WrapClient(fake.NewFakeClient()) - es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "es"}} + es := v1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "es"}} ctx := upscaleCtx{ k8sClient: k8sClient, es: es, @@ -293,18 +293,18 @@ func Test_adjustStatefulSetReplicas(t *testing.T) { } func Test_adjustZenConfig(t *testing.T) { - bootstrappedES := v1alpha1.Elasticsearch{ + bootstrappedES := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: TestEsName, Namespace: TestEsNamespace, Annotations: map[string]string{ClusterUUIDAnnotationName: "uuid"}, }, } - notBootstrappedES := v1alpha1.Elasticsearch{} + notBootstrappedES := v1beta1.Elasticsearch{} tests := []struct { name string - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch statefulSet sset.TestSset pods []runtime.Object wantMinimumMasterNodesSet bool diff --git a/pkg/controller/elasticsearch/elasticsearch_controller.go b/pkg/controller/elasticsearch/elasticsearch_controller.go index 834919b4fa..de7585bee7 100644 --- a/pkg/controller/elasticsearch/elasticsearch_controller.go +++ b/pkg/controller/elasticsearch/elasticsearch_controller.go @@ -8,7 +8,7 @@ import ( "fmt" "sync/atomic" - elasticsearchv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + elasticsearchv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" @@ -86,7 +86,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) (controller.Controller, er func addWatches(c controller.Controller, r *ReconcileElasticsearch) error { // Watch for changes to Elasticsearch if err := c.Watch( - &source.Kind{Type: &elasticsearchv1alpha1.Elasticsearch{}}, &handler.EnqueueRequestForObject{}, + &source.Kind{Type: &elasticsearchv1beta1.Elasticsearch{}}, &handler.EnqueueRequestForObject{}, ); err != nil { return err } @@ -95,7 +95,7 @@ func addWatches(c controller.Controller, r *ReconcileElasticsearch) error { if err := c.Watch( &source.Kind{Type: &appsv1.StatefulSet{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &elasticsearchv1alpha1.Elasticsearch{}, + OwnerType: &elasticsearchv1beta1.Elasticsearch{}, }, ); err != nil { return err @@ -127,7 +127,7 @@ func addWatches(c controller.Controller, r *ReconcileElasticsearch) error { // Watch services if err := c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &elasticsearchv1alpha1.Elasticsearch{}, + OwnerType: &elasticsearchv1beta1.Elasticsearch{}, }); err != nil { return err } @@ -139,7 +139,7 @@ func addWatches(c controller.Controller, r *ReconcileElasticsearch) error { if err := r.dynamicWatches.Secrets.AddHandler(&watches.OwnerWatch{ EnqueueRequestForOwner: handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &elasticsearchv1alpha1.Elasticsearch{}, + OwnerType: &elasticsearchv1beta1.Elasticsearch{}, }, }); err != nil { return err @@ -182,7 +182,7 @@ func (r *ReconcileElasticsearch) Reconcile(request reconcile.Request) (reconcile defer common.LogReconciliationRun(log, request, &r.iteration)() // Fetch the Elasticsearch instance - es := elasticsearchv1alpha1.Elasticsearch{} + es := elasticsearchv1beta1.Elasticsearch{} err := r.Get(request.NamespacedName, &es) if err != nil { if apierrors.IsNotFound(err) { @@ -229,7 +229,7 @@ func (r *ReconcileElasticsearch) Reconcile(request reconcile.Request) (reconcile } func (r *ReconcileElasticsearch) internalReconcile( - es elasticsearchv1alpha1.Elasticsearch, + es elasticsearchv1beta1.Elasticsearch, reconcileState *esreconcile.State, ) *reconciler.Results { results := &reconciler.Results{} @@ -278,7 +278,7 @@ func (r *ReconcileElasticsearch) internalReconcile( } func (r *ReconcileElasticsearch) updateStatus( - es elasticsearchv1alpha1.Elasticsearch, + es elasticsearchv1beta1.Elasticsearch, reconcileState *esreconcile.State, ) error { log.Info("Updating status", "iteration", atomic.LoadUint64(&r.iteration), "namespace", es.Namespace, "es_name", es.Name) @@ -295,7 +295,7 @@ func (r *ReconcileElasticsearch) updateStatus( // finalizersFor returns the list of finalizers applying to a given es cluster func (r *ReconcileElasticsearch) finalizersFor( - es elasticsearchv1alpha1.Elasticsearch, + es elasticsearchv1beta1.Elasticsearch, ) []finalizer.Finalizer { clusterName := k8s.ExtractNamespacedName(&es) return []finalizer.Finalizer{ diff --git a/pkg/controller/elasticsearch/label/label.go b/pkg/controller/elasticsearch/label/label.go index cb7f77a8df..3156ef3d5e 100644 --- a/pkg/controller/elasticsearch/label/label.go +++ b/pkg/controller/elasticsearch/label/label.go @@ -7,7 +7,7 @@ package label import ( "fmt" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/pkg/errors" @@ -112,7 +112,7 @@ func NewPodLabels( es types.NamespacedName, ssetName string, version version.Version, - nodeRoles v1alpha1.Node, + nodeRoles v1beta1.Node, configHash string, scheme string, ) (map[string]string, error) { @@ -152,7 +152,7 @@ func NewStatefulSetLabels(es types.NamespacedName, ssetName string) map[string]s } // NewLabelSelectorForElasticsearch returns a labels.Selector that matches the labels as constructed by NewLabels -func NewLabelSelectorForElasticsearch(es v1alpha1.Elasticsearch) client.MatchingLabels { +func NewLabelSelectorForElasticsearch(es v1beta1.Elasticsearch) client.MatchingLabels { return NewLabelSelectorForElasticsearchClusterName(es.Name) } diff --git a/pkg/controller/elasticsearch/license/apply_test.go b/pkg/controller/elasticsearch/license/apply_test.go index a3c3ba0236..f64a0ef7f9 100644 --- a/pkg/controller/elasticsearch/license/apply_test.go +++ b/pkg/controller/elasticsearch/license/apply_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" @@ -209,7 +209,7 @@ var _ k8s.Client = &fakeClient{} func registerScheme(t *testing.T) *runtime.Scheme { sc := scheme.Scheme - if err := v1alpha1.SchemeBuilder.AddToScheme(sc); err != nil { + if err := v1beta1.SchemeBuilder.AddToScheme(sc); err != nil { assert.Fail(t, "failed to build custom scheme") } return sc diff --git a/pkg/controller/elasticsearch/license/reconcile.go b/pkg/controller/elasticsearch/license/reconcile.go index b37ab83317..45052b6c69 100644 --- a/pkg/controller/elasticsearch/license/reconcile.go +++ b/pkg/controller/elasticsearch/license/reconcile.go @@ -5,7 +5,7 @@ package license import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) @@ -13,7 +13,7 @@ import ( // Reconcile reconciles the current Elasticsearch license with the desired one. func Reconcile( c k8s.Client, - esCluster v1alpha1.Elasticsearch, + esCluster v1beta1.Elasticsearch, clusterClient esclient.Client, current *esclient.License, ) error { diff --git a/pkg/controller/elasticsearch/name/name.go b/pkg/controller/elasticsearch/name/name.go index 6a88719b32..37e6b85a82 100644 --- a/pkg/controller/elasticsearch/name/name.go +++ b/pkg/controller/elasticsearch/name/name.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common_name "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/pkg/errors" @@ -51,7 +51,7 @@ var ( ) // Validate checks the validity of resource names that will be generated by the given Elasticsearch object. -func Validate(es v1alpha1.Elasticsearch) error { +func Validate(es v1beta1.Elasticsearch) error { esName := k8s.ExtractNamespacedName(&es).Name if len(esName) > common_name.MaxResourceNameLength { return fmt.Errorf("name exceeds maximum allowed length of %d", common_name.MaxResourceNameLength) diff --git a/pkg/controller/elasticsearch/name/name_test.go b/pkg/controller/elasticsearch/name/name_test.go index a70f6d9741..a557749e44 100644 --- a/pkg/controller/elasticsearch/name/name_test.go +++ b/pkg/controller/elasticsearch/name/name_test.go @@ -7,7 +7,7 @@ package name import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -51,16 +51,16 @@ func TestValidate(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - es := v1alpha1.Elasticsearch{ + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: tc.esName, Namespace: "test", }, - Spec: v1alpha1.ElasticsearchSpec{}, + Spec: v1beta1.ElasticsearchSpec{}, } for _, nodeSpecName := range tc.nodeSpecNames { - es.Spec.Nodes = append(es.Spec.Nodes, v1alpha1.NodeSpec{Name: nodeSpecName, NodeCount: 10}) + es.Spec.Nodes = append(es.Spec.Nodes, v1beta1.NodeSpec{Name: nodeSpecName, NodeCount: 10}) } err := Validate(es) diff --git a/pkg/controller/elasticsearch/nodespec/defaults.go b/pkg/controller/elasticsearch/nodespec/defaults.go index 700021613f..fb21a1fa6a 100644 --- a/pkg/controller/elasticsearch/nodespec/defaults.go +++ b/pkg/controller/elasticsearch/nodespec/defaults.go @@ -7,7 +7,7 @@ package nodespec import ( "path" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -51,7 +51,7 @@ var ( ) // DefaultEnvVars are environment variables injected into Elasticsearch pods. -func DefaultEnvVars(httpCfg v1alpha1.HTTPConfig) []corev1.EnvVar { +func DefaultEnvVars(httpCfg v1beta1.HTTPConfig) []corev1.EnvVar { return append( defaults.PodDownwardEnvVars, []corev1.EnvVar{ diff --git a/pkg/controller/elasticsearch/nodespec/podspec.go b/pkg/controller/elasticsearch/nodespec/podspec.go index 7de94df546..df09397895 100644 --- a/pkg/controller/elasticsearch/nodespec/podspec.go +++ b/pkg/controller/elasticsearch/nodespec/podspec.go @@ -10,7 +10,7 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" @@ -27,8 +27,8 @@ import ( // BuildPodTemplateSpec builds a new PodTemplateSpec for an Elasticsearch node. func BuildPodTemplateSpec( - es v1alpha1.Elasticsearch, - nodeSpec v1alpha1.NodeSpec, + es v1beta1.Elasticsearch, + nodeSpec v1beta1.NodeSpec, cfg settings.CanonicalConfig, keystoreResources *keystore.Resources, ) (corev1.PodTemplateSpec, error) { @@ -38,7 +38,7 @@ func BuildPodTemplateSpec( return corev1.PodTemplateSpec{}, err } - builder := defaults.NewPodTemplateBuilder(nodeSpec.PodTemplate, v1alpha1.ElasticsearchContainerName). + builder := defaults.NewPodTemplateBuilder(nodeSpec.PodTemplate, v1beta1.ElasticsearchContainerName). WithDockerImage(es.Spec.Image, stringsutil.Concat(DefaultImageRepository, ":", es.Spec.Version)) initContainers, err := initcontainer.NewInitContainers( @@ -77,9 +77,9 @@ func transportCertificatesVolume(esName string) volume.SecretVolume { } func buildLabels( - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, cfg settings.CanonicalConfig, - nodeSpec v1alpha1.NodeSpec, + nodeSpec v1beta1.NodeSpec, keystoreResources *keystore.Resources, ) (map[string]string, error) { // label with a hash of the config to rotate the pod on config changes diff --git a/pkg/controller/elasticsearch/nodespec/podspec_test.go b/pkg/controller/elasticsearch/nodespec/podspec_test.go index 12337d2b72..b89e83c2f8 100644 --- a/pkg/controller/elasticsearch/nodespec/podspec_test.go +++ b/pkg/controller/elasticsearch/nodespec/podspec_test.go @@ -8,8 +8,8 @@ import ( "sort" "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/certificates" @@ -22,7 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -var sampleES = v1alpha1.Elasticsearch{ +var sampleES = v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "name", @@ -33,13 +33,13 @@ var sampleES = v1alpha1.Elasticsearch{ "cluster-annotation-name": "cluster-annotation-value", }, }, - Spec: v1alpha1.ElasticsearchSpec{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "nodespec-1", NodeCount: 2, - Config: &commonv1alpha1.Config{ + Config: &commonv1beta1.Config{ Data: map[string]interface{}{ "node.attr.foo": "bar", "node.master": "true", diff --git a/pkg/controller/elasticsearch/nodespec/resources.go b/pkg/controller/elasticsearch/nodespec/resources.go index b144b3d1a7..e9ac21595a 100644 --- a/pkg/controller/elasticsearch/nodespec/resources.go +++ b/pkg/controller/elasticsearch/nodespec/resources.go @@ -9,8 +9,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/certificates" @@ -37,7 +37,7 @@ func (l ResourcesList) StatefulSets() sset.StatefulSetList { return ssetList } -func BuildExpectedResources(es v1alpha1.Elasticsearch, keystoreResources *keystore.Resources, scheme *runtime.Scheme, certResources *certificates.CertificateResources) (ResourcesList, error) { +func BuildExpectedResources(es v1beta1.Elasticsearch, keystoreResources *keystore.Resources, scheme *runtime.Scheme, certResources *certificates.CertificateResources) (ResourcesList, error) { nodesResources := make(ResourcesList, 0, len(es.Spec.Nodes)) ver, err := version.Parse(es.Spec.Version) @@ -47,7 +47,7 @@ func BuildExpectedResources(es v1alpha1.Elasticsearch, keystoreResources *keysto for _, nodeSpec := range es.Spec.Nodes { // build es config - userCfg := commonv1alpha1.Config{} + userCfg := commonv1beta1.Config{} if nodeSpec.Config != nil { userCfg = *nodeSpec.Config } diff --git a/pkg/controller/elasticsearch/nodespec/statefulset.go b/pkg/controller/elasticsearch/nodespec/statefulset.go index e60701f9d3..90ac9e1514 100644 --- a/pkg/controller/elasticsearch/nodespec/statefulset.go +++ b/pkg/controller/elasticsearch/nodespec/statefulset.go @@ -7,7 +7,7 @@ package nodespec import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" @@ -47,8 +47,8 @@ func HeadlessService(es types.NamespacedName, ssetName string) corev1.Service { } func BuildStatefulSet( - es v1alpha1.Elasticsearch, - nodeSpec v1alpha1.NodeSpec, + es v1beta1.Elasticsearch, + nodeSpec v1beta1.NodeSpec, cfg settings.CanonicalConfig, keystoreResources *keystore.Resources, scheme *runtime.Scheme, diff --git a/pkg/controller/elasticsearch/nodespec/volumes.go b/pkg/controller/elasticsearch/nodespec/volumes.go index fd377b5c6f..6346f6eec7 100644 --- a/pkg/controller/elasticsearch/nodespec/volumes.go +++ b/pkg/controller/elasticsearch/nodespec/volumes.go @@ -7,7 +7,7 @@ package nodespec import ( corev1 "k8s.io/api/core/v1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" "github.com/elastic/cloud-on-k8s/pkg/controller/common/volume" @@ -18,7 +18,7 @@ import ( esvolume "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/volume" ) -func buildVolumes(esName string, nodeSpec v1alpha1.NodeSpec, keystoreResources *keystore.Resources) ([]corev1.Volume, []corev1.VolumeMount) { +func buildVolumes(esName string, nodeSpec v1beta1.NodeSpec, keystoreResources *keystore.Resources) ([]corev1.Volume, []corev1.VolumeMount) { configVolume := settings.ConfigSecretVolume(name.StatefulSet(esName, nodeSpec.Name)) probeSecret := volume.NewSelectiveSecretVolumeWithMountPath( diff --git a/pkg/controller/elasticsearch/pdb/reconcile.go b/pkg/controller/elasticsearch/pdb/reconcile.go index f9bc8f91a5..017f2e672b 100644 --- a/pkg/controller/elasticsearch/pdb/reconcile.go +++ b/pkg/controller/elasticsearch/pdb/reconcile.go @@ -5,6 +5,14 @@ package pdb import ( + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + esv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" + "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" + "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "k8s.io/api/policy/v1beta1" "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -12,21 +20,12 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" - "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" - "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) // Reconcile ensures that a PodDisruptionBudget exists for this cluster, inheriting the spec content. // The default PDB we setup dynamically adapts MinAvailable to the number of nodes in the cluster. // If the spec has disabled the default PDB, it will ensure none exist. -func Reconcile(k8sClient k8s.Client, scheme *runtime.Scheme, es v1alpha1.Elasticsearch, statefulSets sset.StatefulSetList) error { +func Reconcile(k8sClient k8s.Client, scheme *runtime.Scheme, es esv1beta1.Elasticsearch, statefulSets sset.StatefulSetList) error { expected, err := expectedPDB(es, statefulSets, scheme) if err != nil { return err @@ -60,7 +59,7 @@ func Reconcile(k8sClient k8s.Client, scheme *runtime.Scheme, es v1alpha1.Elastic } // deleteDefaultPDB deletes the default pdb if it exists. -func deleteDefaultPDB(k8sClient k8s.Client, es v1alpha1.Elasticsearch) error { +func deleteDefaultPDB(k8sClient k8s.Client, es esv1beta1.Elasticsearch) error { // we do this by getting first because that is a local cache read, // versus a Delete call, which would hit the API. pdb := v1beta1.PodDisruptionBudget{ @@ -83,13 +82,13 @@ func deleteDefaultPDB(k8sClient k8s.Client, es v1alpha1.Elasticsearch) error { // expectedPDB returns a PDB according to the given ES spec. // It may return nil if the PDB has been explicitly disabled in the ES spec. -func expectedPDB(es v1alpha1.Elasticsearch, statefulSets sset.StatefulSetList, scheme *runtime.Scheme) (*v1beta1.PodDisruptionBudget, error) { +func expectedPDB(es esv1beta1.Elasticsearch, statefulSets sset.StatefulSetList, scheme *runtime.Scheme) (*v1beta1.PodDisruptionBudget, error) { template := es.Spec.PodDisruptionBudget.DeepCopy() if template.IsDisabled() { return nil, nil } if template == nil { - template = &commonv1alpha1.PodDisruptionBudgetTemplate{} + template = &commonv1beta1.PodDisruptionBudgetTemplate{} } expected := v1beta1.PodDisruptionBudget{ @@ -119,7 +118,7 @@ func expectedPDB(es v1alpha1.Elasticsearch, statefulSets sset.StatefulSetList, s // buildPDBSpec returns a PDBSpec computed from the current StatefulSets, // considering the cluster health and topology. -func buildPDBSpec(es v1alpha1.Elasticsearch, statefulSets sset.StatefulSetList) v1beta1.PodDisruptionBudgetSpec { +func buildPDBSpec(es esv1beta1.Elasticsearch, statefulSets sset.StatefulSetList) v1beta1.PodDisruptionBudgetSpec { // compute MinAvailable based on the maximum number of Pods we're supposed to have nodeCount := statefulSets.ExpectedNodeCount() // maybe allow some Pods to be disrupted @@ -142,8 +141,8 @@ func buildPDBSpec(es v1alpha1.Elasticsearch, statefulSets sset.StatefulSetList) } // allowedDisruptions returns the number of Pods that we allow to be disrupted while keeping the cluster healthy. -func allowedDisruptions(es v1alpha1.Elasticsearch, actualSsets sset.StatefulSetList) int32 { - if es.Status.Health != v1alpha1.ElasticsearchGreenHealth { +func allowedDisruptions(es esv1beta1.Elasticsearch, actualSsets sset.StatefulSetList) int32 { + if es.Status.Health != esv1beta1.ElasticsearchGreenHealth { // A non-green cluster may become red if we disrupt one node, don't allow it. // The health information we're using here may be out-of-date, that's best effort. return 0 diff --git a/pkg/controller/elasticsearch/pdb/reconcile_test.go b/pkg/controller/elasticsearch/pdb/reconcile_test.go index b9a197a44d..f7df2e99d8 100644 --- a/pkg/controller/elasticsearch/pdb/reconcile_test.go +++ b/pkg/controller/elasticsearch/pdb/reconcile_test.go @@ -8,6 +8,14 @@ import ( "reflect" "testing" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + esv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/controller/common" + "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" + "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/require" "k8s.io/api/policy/v1beta1" "k8s.io/apimachinery/pkg/api/errors" @@ -17,19 +25,10 @@ import ( "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/controller/common" - "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" - "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) func TestReconcile(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, esv1beta1.AddToScheme(scheme.Scheme)) defaultPDB := func() *v1beta1.PodDisruptionBudget { return &v1beta1.PodDisruptionBudget{ ObjectMeta: metav1.ObjectMeta{ @@ -48,10 +47,10 @@ func TestReconcile(t *testing.T) { }, } } - defaultEs := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}} + defaultEs := esv1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}} type args struct { k8sClient k8s.Client - es v1alpha1.Elasticsearch + es esv1beta1.Elasticsearch statefulSets sset.StatefulSetList } tests := []struct { @@ -105,9 +104,9 @@ func TestReconcile(t *testing.T) { name: "pdb disabled in the ES spec: should delete the existing one", args: args{ k8sClient: k8s.WrapClient(fake.NewFakeClient(defaultPDB())), - es: v1alpha1.Elasticsearch{ + es: esv1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}, - Spec: v1alpha1.ElasticsearchSpec{PodDisruptionBudget: &commonv1alpha1.PodDisruptionBudgetTemplate{}}, + Spec: esv1beta1.ElasticsearchSpec{PodDisruptionBudget: &commonv1beta1.PodDisruptionBudgetTemplate{}}, }, statefulSets: sset.StatefulSetList{sset.TestSset{Replicas: 3, Master: true, Data: true}.Build()}, }, @@ -138,7 +137,7 @@ func withHashLabel(pdb *v1beta1.PodDisruptionBudget) *v1beta1.PodDisruptionBudge return pdb } -func withOwnerRef(pdb *v1beta1.PodDisruptionBudget, es v1alpha1.Elasticsearch) *v1beta1.PodDisruptionBudget { +func withOwnerRef(pdb *v1beta1.PodDisruptionBudget, es esv1beta1.Elasticsearch) *v1beta1.PodDisruptionBudget { if err := controllerutil.SetControllerReference(&es, pdb, scheme.Scheme); err != nil { panic(err) } @@ -150,9 +149,9 @@ func intStrPtr(intStr intstr.IntOrString) *intstr.IntOrString { } func Test_expectedPDB(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, esv1beta1.AddToScheme(scheme.Scheme)) type args struct { - es v1alpha1.Elasticsearch + es esv1beta1.Elasticsearch statefulSets sset.StatefulSetList } tests := []struct { @@ -163,7 +162,7 @@ func Test_expectedPDB(t *testing.T) { { name: "PDB disabled in the spec", args: args{ - es: v1alpha1.Elasticsearch{Spec: v1alpha1.ElasticsearchSpec{PodDisruptionBudget: &commonv1alpha1.PodDisruptionBudgetTemplate{}}}, + es: esv1beta1.Elasticsearch{Spec: esv1beta1.ElasticsearchSpec{PodDisruptionBudget: &commonv1beta1.PodDisruptionBudgetTemplate{}}}, statefulSets: sset.StatefulSetList{sset.TestSset{Replicas: 3, Master: true, Data: true}.Build()}, }, want: nil, @@ -171,7 +170,7 @@ func Test_expectedPDB(t *testing.T) { { name: "Build default PDB", args: args{ - es: v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}}, + es: esv1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}}, statefulSets: sset.StatefulSetList{sset.TestSset{Replicas: 3, Master: true, Data: true}.Build()}, }, want: &v1beta1.PodDisruptionBudget{ @@ -194,10 +193,10 @@ func Test_expectedPDB(t *testing.T) { { name: "Inherit user-provided labels", args: args{ - es: v1alpha1.Elasticsearch{ + es: esv1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}, - Spec: v1alpha1.ElasticsearchSpec{ - PodDisruptionBudget: &commonv1alpha1.PodDisruptionBudgetTemplate{ + Spec: esv1beta1.ElasticsearchSpec{ + PodDisruptionBudget: &commonv1beta1.PodDisruptionBudgetTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"a": "b", "c": "d"}, }}, @@ -225,10 +224,10 @@ func Test_expectedPDB(t *testing.T) { { name: "Use user-provided PDB spec", args: args{ - es: v1alpha1.Elasticsearch{ + es: esv1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "ns"}, - Spec: v1alpha1.ElasticsearchSpec{ - PodDisruptionBudget: &commonv1alpha1.PodDisruptionBudgetTemplate{ + Spec: esv1beta1.ElasticsearchSpec{ + PodDisruptionBudget: &commonv1beta1.PodDisruptionBudgetTemplate{ Spec: v1beta1.PodDisruptionBudgetSpec{MinAvailable: intStrPtr(intstr.FromInt(42))}}, }, }, @@ -263,7 +262,7 @@ func Test_expectedPDB(t *testing.T) { func Test_allowedDisruptions(t *testing.T) { type args struct { - es v1alpha1.Elasticsearch + es esv1beta1.Elasticsearch actualSsets sset.StatefulSetList } tests := []struct { @@ -274,7 +273,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "no health reported: no disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{}}, actualSsets: sset.StatefulSetList{sset.TestSset{Replicas: 3}.Build()}, }, want: 0, @@ -282,7 +281,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "yellow health: no disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchYellowHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchYellowHealth}}, actualSsets: sset.StatefulSetList{sset.TestSset{Replicas: 3}.Build()}, }, want: 0, @@ -290,7 +289,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "red health: no disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchRedHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchRedHealth}}, actualSsets: sset.StatefulSetList{sset.TestSset{Replicas: 3, Master: true, Data: true}.Build()}, }, want: 0, @@ -298,7 +297,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "unknown health: no disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchUnknownHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchUnknownHealth}}, actualSsets: sset.StatefulSetList{sset.TestSset{Replicas: 3, Master: true, Data: true}.Build()}, }, want: 0, @@ -306,7 +305,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "green health: 1 disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchGreenHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchGreenHealth}}, actualSsets: sset.StatefulSetList{sset.TestSset{Replicas: 3, Master: true, Data: true}.Build()}, }, want: 1, @@ -314,7 +313,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "green health but single-node cluster: 0 disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchGreenHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchGreenHealth}}, actualSsets: sset.StatefulSetList{sset.TestSset{Replicas: 1, Master: true, Data: true}.Build()}, }, want: 0, @@ -322,7 +321,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "green health but only 1 master: 0 disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchGreenHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchGreenHealth}}, actualSsets: sset.StatefulSetList{ sset.TestSset{Replicas: 1, Master: true, Data: false}.Build(), sset.TestSset{Replicas: 3, Master: false, Data: true}.Build(), @@ -333,7 +332,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "green health but only 1 data node: 0 disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchGreenHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchGreenHealth}}, actualSsets: sset.StatefulSetList{ sset.TestSset{Replicas: 3, Master: true, Data: false}.Build(), sset.TestSset{Replicas: 1, Master: false, Data: true}.Build(), @@ -344,7 +343,7 @@ func Test_allowedDisruptions(t *testing.T) { { name: "green health but only 1 ingest node: 0 disruption allowed", args: args{ - es: v1alpha1.Elasticsearch{Status: v1alpha1.ElasticsearchStatus{Health: v1alpha1.ElasticsearchGreenHealth}}, + es: esv1beta1.Elasticsearch{Status: esv1beta1.ElasticsearchStatus{Health: esv1beta1.ElasticsearchGreenHealth}}, actualSsets: sset.StatefulSetList{ sset.TestSset{Replicas: 3, Master: true, Data: true, Ingest: false}.Build(), sset.TestSset{Replicas: 1, Ingest: true, Data: true}.Build(), diff --git a/pkg/controller/elasticsearch/reconcile/resources_state.go b/pkg/controller/elasticsearch/reconcile/resources_state.go index c0d1c0c285..7cd9b11b34 100644 --- a/pkg/controller/elasticsearch/reconcile/resources_state.go +++ b/pkg/controller/elasticsearch/reconcile/resources_state.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/services" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -30,7 +30,7 @@ type ResourcesState struct { } // NewResourcesStateFromAPI reflects the current ResourcesState from the API -func NewResourcesStateFromAPI(c k8s.Client, es v1alpha1.Elasticsearch) (*ResourcesState, error) { +func NewResourcesStateFromAPI(c k8s.Client, es v1beta1.Elasticsearch) (*ResourcesState, error) { labelSelector := label.NewLabelSelectorForElasticsearch(es) allPods, err := getPods(c, es, labelSelector) @@ -78,7 +78,7 @@ func NewResourcesStateFromAPI(c k8s.Client, es v1alpha1.Elasticsearch) (*Resourc // getPods returns list of pods in the current namespace with a specific set of selectors. func getPods( c k8s.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, labelSelector client.MatchingLabels, ) ([]corev1.Pod, error) { var podList corev1.PodList diff --git a/pkg/controller/elasticsearch/reconcile/state.go b/pkg/controller/elasticsearch/reconcile/state.go index 241723bcb4..0e38e7ddf5 100644 --- a/pkg/controller/elasticsearch/reconcile/state.go +++ b/pkg/controller/elasticsearch/reconcile/state.go @@ -7,7 +7,7 @@ package reconcile import ( "reflect" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/observer" @@ -19,12 +19,12 @@ import ( // Elasticsearch resource for status updates. type State struct { *events.Recorder - cluster v1alpha1.Elasticsearch - status v1alpha1.ElasticsearchStatus + cluster v1beta1.Elasticsearch + status v1beta1.ElasticsearchStatus } // NewState creates a new reconcile state based on the given cluster -func NewState(c v1alpha1.Elasticsearch) *State { +func NewState(c v1beta1.Elasticsearch) *State { return &State{Recorder: events.NewRecorder(), cluster: c, status: *c.Status.DeepCopy()} } @@ -40,16 +40,16 @@ func AvailableElasticsearchNodes(pods []corev1.Pod) []corev1.Pod { } func (s *State) updateWithPhase( - phase v1alpha1.ElasticsearchOrchestrationPhase, + phase v1beta1.ElasticsearchOrchestrationPhase, resourcesState ResourcesState, observedState observer.State, ) *State { s.status.AvailableNodes = len(AvailableElasticsearchNodes(resourcesState.CurrentPods)) s.status.Phase = phase - s.status.Health = v1alpha1.ElasticsearchUnknownHealth + s.status.Health = v1beta1.ElasticsearchUnknownHealth if observedState.ClusterHealth != nil && observedState.ClusterHealth.Status != "" { - s.status.Health = v1alpha1.ElasticsearchHealth(observedState.ClusterHealth.Status) + s.status.Health = v1beta1.ElasticsearchHealth(observedState.ClusterHealth.Status) } return s } @@ -67,19 +67,19 @@ func (s *State) UpdateElasticsearchReady( resourcesState ResourcesState, observedState observer.State, ) *State { - return s.updateWithPhase(v1alpha1.ElasticsearchReadyPhase, resourcesState, observedState) + return s.updateWithPhase(v1beta1.ElasticsearchReadyPhase, resourcesState, observedState) } // IsElasticsearchReady reports if Elasticsearch is ready. func (s *State) IsElasticsearchReady(observedState observer.State) bool { - return s.status.Phase == v1alpha1.ElasticsearchReadyPhase + return s.status.Phase == v1beta1.ElasticsearchReadyPhase } // UpdateElasticsearchApplyingChanges marks Elasticsearch as being the applying changes phase in the resource status. func (s *State) UpdateElasticsearchApplyingChanges(pods []corev1.Pod) *State { s.status.AvailableNodes = len(AvailableElasticsearchNodes(pods)) - s.status.Phase = v1alpha1.ElasticsearchApplyingChangesPhase - s.status.Health = v1alpha1.ElasticsearchRedHealth + s.status.Phase = v1beta1.ElasticsearchApplyingChangesPhase + s.status.Health = v1beta1.ElasticsearchRedHealth return s } @@ -93,13 +93,13 @@ func (s *State) UpdateElasticsearchMigrating( events.EventReasonDelayed, "Requested topology change delayed by data migration", ) - return s.updateWithPhase(v1alpha1.ElasticsearchMigratingDataPhase, resourcesState, observedState) + return s.updateWithPhase(v1beta1.ElasticsearchMigratingDataPhase, resourcesState, observedState) } // Apply takes the current Elasticsearch status, compares it to the previous status, and updates the status accordingly. // It returns the events to emit and an updated version of the Elasticsearch cluster resource with // the current status applied to its status sub-resource. -func (s *State) Apply() ([]events.Event, *v1alpha1.Elasticsearch) { +func (s *State) Apply() ([]events.Event, *v1beta1.Elasticsearch) { previous := s.cluster.Status current := s.status if reflect.DeepEqual(previous, current) { @@ -113,7 +113,7 @@ func (s *State) Apply() ([]events.Event, *v1alpha1.Elasticsearch) { } func (s *State) UpdateElasticsearchInvalid(results []validation.Result) { - s.status.Phase = v1alpha1.ElasticsearchResourceInvalid + s.status.Phase = v1beta1.ElasticsearchResourceInvalid for _, r := range results { s.AddEvent(corev1.EventTypeWarning, events.EventReasonValidation, r.Reason) } diff --git a/pkg/controller/elasticsearch/reconcile/state_test.go b/pkg/controller/elasticsearch/reconcile/state_test.go index 30d1edcbab..98960df2b4 100644 --- a/pkg/controller/elasticsearch/reconcile/state_test.go +++ b/pkg/controller/elasticsearch/reconcile/state_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - v1alpha12 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + v1beta12 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/observer" @@ -133,37 +133,37 @@ func TestNodesAvailable(t *testing.T) { func TestState_Apply(t *testing.T) { tests := []struct { name string - cluster v1alpha1.Elasticsearch + cluster v1beta1.Elasticsearch effects func(s *State) wantEvents []events.Event - wantStatus *v1alpha1.ElasticsearchStatus + wantStatus *v1beta1.ElasticsearchStatus }{ { name: "defaults", - cluster: v1alpha1.Elasticsearch{}, + cluster: v1beta1.Elasticsearch{}, wantEvents: []events.Event{}, wantStatus: nil, }, { name: "no degraded health event on cluster formation", - cluster: v1alpha1.Elasticsearch{}, + cluster: v1beta1.Elasticsearch{}, effects: func(s *State) { s.UpdateElasticsearchApplyingChanges([]corev1.Pod{}) }, wantEvents: []events.Event{}, - wantStatus: &v1alpha1.ElasticsearchStatus{ - ReconcilerStatus: v1alpha12.ReconcilerStatus{ + wantStatus: &v1beta1.ElasticsearchStatus{ + ReconcilerStatus: v1beta12.ReconcilerStatus{ AvailableNodes: 0, }, - Health: v1alpha1.ElasticsearchRedHealth, - Phase: v1alpha1.ElasticsearchApplyingChangesPhase, + Health: v1beta1.ElasticsearchRedHealth, + Phase: v1beta1.ElasticsearchApplyingChangesPhase, }, }, { name: "no degraded health event when cluster info is unknown", - cluster: v1alpha1.Elasticsearch{ - Status: v1alpha1.ElasticsearchStatus{ - Health: v1alpha1.ElasticsearchGreenHealth, + cluster: v1beta1.Elasticsearch{ + Status: v1beta1.ElasticsearchStatus{ + Health: v1beta1.ElasticsearchGreenHealth, }, }, effects: func(s *State) { @@ -173,31 +173,31 @@ func TestState_Apply(t *testing.T) { }) }, wantEvents: []events.Event{}, - wantStatus: &v1alpha1.ElasticsearchStatus{ - ReconcilerStatus: v1alpha12.ReconcilerStatus{ + wantStatus: &v1beta1.ElasticsearchStatus{ + ReconcilerStatus: v1beta12.ReconcilerStatus{ AvailableNodes: 0, }, - Health: v1alpha1.ElasticsearchUnknownHealth, + Health: v1beta1.ElasticsearchUnknownHealth, Phase: "", }, }, { name: "health degraded", - cluster: v1alpha1.Elasticsearch{ - Status: v1alpha1.ElasticsearchStatus{ - Health: v1alpha1.ElasticsearchGreenHealth, + cluster: v1beta1.Elasticsearch{ + Status: v1beta1.ElasticsearchStatus{ + Health: v1beta1.ElasticsearchGreenHealth, }, }, effects: func(s *State) { s.UpdateElasticsearchApplyingChanges([]corev1.Pod{}) }, wantEvents: []events.Event{{EventType: corev1.EventTypeWarning, Reason: events.EventReasonUnhealthy, Message: "Elasticsearch cluster health degraded"}}, - wantStatus: &v1alpha1.ElasticsearchStatus{ - ReconcilerStatus: v1alpha12.ReconcilerStatus{ + wantStatus: &v1beta1.ElasticsearchStatus{ + ReconcilerStatus: v1beta12.ReconcilerStatus{ AvailableNodes: 0, }, - Health: v1alpha1.ElasticsearchRedHealth, - Phase: v1alpha1.ElasticsearchApplyingChangesPhase, + Health: v1beta1.ElasticsearchRedHealth, + Phase: v1beta1.ElasticsearchApplyingChangesPhase, }, }, } @@ -211,7 +211,7 @@ func TestState_Apply(t *testing.T) { if !reflect.DeepEqual(events, tt.wantEvents) { t.Errorf("State.Apply() events = %v, wantEvents %v", events, tt.wantEvents) } - var actual *v1alpha1.ElasticsearchStatus + var actual *v1beta1.ElasticsearchStatus if cluster != nil { actual = &cluster.Status } @@ -229,31 +229,31 @@ func TestState_UpdateElasticsearchState(t *testing.T) { } tests := []struct { name string - cluster v1alpha1.Elasticsearch + cluster v1beta1.Elasticsearch args args stateAssertions func(s *State) }{ { name: "phase is not changed by default", - cluster: v1alpha1.Elasticsearch{ - Status: v1alpha1.ElasticsearchStatus{ - Phase: v1alpha1.ElasticsearchApplyingChangesPhase, + cluster: v1beta1.Elasticsearch{ + Status: v1beta1.ElasticsearchStatus{ + Phase: v1beta1.ElasticsearchApplyingChangesPhase, }, }, stateAssertions: func(s *State) { - assert.EqualValues(t, v1alpha1.ElasticsearchApplyingChangesPhase, s.status.Phase) + assert.EqualValues(t, v1beta1.ElasticsearchApplyingChangesPhase, s.status.Phase) }, }, { name: "health is unknown by default", - cluster: v1alpha1.Elasticsearch{}, + cluster: v1beta1.Elasticsearch{}, stateAssertions: func(s *State) { - assert.EqualValues(t, v1alpha1.ElasticsearchUnknownHealth, s.status.Health) + assert.EqualValues(t, v1beta1.ElasticsearchUnknownHealth, s.status.Health) }, }, { name: "health is set if returned by Elasticsearch", - cluster: v1alpha1.Elasticsearch{}, + cluster: v1beta1.Elasticsearch{}, args: args{ observedState: observer.State{ ClusterHealth: &client.Health{Status: "green"}, @@ -284,18 +284,18 @@ func TestState_UpdateElasticsearchMigrating(t *testing.T) { } tests := []struct { name string - cluster v1alpha1.Elasticsearch + cluster v1beta1.Elasticsearch args args stateAssertions func(s *State) }{ { name: "base case", - cluster: v1alpha1.Elasticsearch{}, + cluster: v1beta1.Elasticsearch{}, args: args{ result: reconcile.Result{RequeueAfter: 10 * time.Minute}, }, stateAssertions: func(s *State) { - assert.EqualValues(t, v1alpha1.ElasticsearchMigratingDataPhase, s.status.Phase) + assert.EqualValues(t, v1beta1.ElasticsearchMigratingDataPhase, s.status.Phase) assert.Equal(t, []events.Event{{EventType: corev1.EventTypeNormal, Reason: events.EventReasonDelayed, Message: "Requested topology change delayed by data migration"}}, s.Recorder.Events()) }, }, diff --git a/pkg/controller/elasticsearch/services/services.go b/pkg/controller/elasticsearch/services/services.go index a38cc60239..ae9f3da10f 100644 --- a/pkg/controller/elasticsearch/services/services.go +++ b/pkg/controller/elasticsearch/services/services.go @@ -12,7 +12,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" @@ -32,13 +32,13 @@ func ExternalServiceName(esName string) string { } // ExternalServiceURL returns the URL used to reach Elasticsearch's external endpoint -func ExternalServiceURL(es v1alpha1.Elasticsearch) string { +func ExternalServiceURL(es v1beta1.Elasticsearch) string { return stringsutil.Concat(es.Spec.HTTP.Scheme(), "://", ExternalServiceName(es.Name), ".", es.Namespace, globalServiceSuffix, ":", strconv.Itoa(network.HTTPPort)) } // NewExternalService returns the external service associated to the given cluster // It is used by users to perform requests against one of the cluster nodes. -func NewExternalService(es v1alpha1.Elasticsearch) *corev1.Service { +func NewExternalService(es v1beta1.Elasticsearch) *corev1.Service { nsn := k8s.ExtractNamespacedName(&es) svc := corev1.Service{ @@ -78,7 +78,7 @@ func IsServiceReady(c k8s.Client, service corev1.Service) (bool, error) { } // GetExternalService returns the external service associated to the given Elasticsearch cluster. -func GetExternalService(c k8s.Client, es v1alpha1.Elasticsearch) (corev1.Service, error) { +func GetExternalService(c k8s.Client, es v1beta1.Elasticsearch) (corev1.Service, error) { var svc corev1.Service namespacedName := types.NamespacedName{ @@ -96,7 +96,7 @@ func GetExternalService(c k8s.Client, es v1alpha1.Elasticsearch) (corev1.Service // ElasticsearchURL calculates the base url for Elasticsearch, taking into account the currently running pods. // If there is an HTTP scheme mismatch between spec and pods we switch to requesting individual pods directly // otherwise this delegates to ExternalServiceURL. -func ElasticsearchURL(es v1alpha1.Elasticsearch, pods []corev1.Pod) string { +func ElasticsearchURL(es v1beta1.Elasticsearch, pods []corev1.Pod) string { var schemeChange bool for _, p := range pods { scheme, exists := p.Labels[label.HTTPSchemeLabelName] diff --git a/pkg/controller/elasticsearch/services/services_test.go b/pkg/controller/elasticsearch/services/services_test.go index b59a08e828..96b508d1d3 100644 --- a/pkg/controller/elasticsearch/services/services_test.go +++ b/pkg/controller/elasticsearch/services/services_test.go @@ -7,7 +7,7 @@ package services import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" @@ -16,7 +16,7 @@ import ( func TestExternalServiceURL(t *testing.T) { type args struct { - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch } tests := []struct { name string @@ -25,7 +25,7 @@ func TestExternalServiceURL(t *testing.T) { }{ { name: "A service URL", - args: args{es: v1alpha1.Elasticsearch{ + args: args{es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "an-es-name", Namespace: "default", @@ -35,7 +35,7 @@ func TestExternalServiceURL(t *testing.T) { }, { name: "Another Service URL", - args: args{es: v1alpha1.Elasticsearch{ + args: args{es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "another-es-name", Namespace: "default", @@ -54,7 +54,7 @@ func TestExternalServiceURL(t *testing.T) { func TestElasticsearchURL(t *testing.T) { type args struct { - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch pods []corev1.Pod } tests := []struct { @@ -65,7 +65,7 @@ func TestElasticsearchURL(t *testing.T) { { name: "default: external service url", args: args{ - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "my-cluster", Namespace: "my-ns", @@ -86,7 +86,7 @@ func TestElasticsearchURL(t *testing.T) { { name: "scheme change in progress: random pod address", args: args{ - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "my-cluster", Namespace: "my-ns", @@ -110,7 +110,7 @@ func TestElasticsearchURL(t *testing.T) { { name: "unexpected: missing pod labels: fallback to service", args: args{ - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "my-cluster", Namespace: "my-ns", @@ -125,7 +125,7 @@ func TestElasticsearchURL(t *testing.T) { { name: "unexpected: partially missing pod labels: fallback to service", args: args{ - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "my-cluster", Namespace: "my-ns", diff --git a/pkg/controller/elasticsearch/settings/canonical_config.go b/pkg/controller/elasticsearch/settings/canonical_config.go index 56925f4b95..c47fb79f87 100644 --- a/pkg/controller/elasticsearch/settings/canonical_config.go +++ b/pkg/controller/elasticsearch/settings/canonical_config.go @@ -5,7 +5,7 @@ package settings import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" ) @@ -20,8 +20,8 @@ func NewCanonicalConfig() CanonicalConfig { } // Unpack returns a typed subset of Elasticsearch settings. -func (c CanonicalConfig) Unpack() (v1alpha1.ElasticsearchSettings, error) { - cfg := v1alpha1.DefaultCfg +func (c CanonicalConfig) Unpack() (v1beta1.ElasticsearchSettings, error) { + cfg := v1beta1.DefaultCfg err := c.CanonicalConfig.Unpack(&cfg) return cfg, err } diff --git a/pkg/controller/elasticsearch/settings/config_volume.go b/pkg/controller/elasticsearch/settings/config_volume.go index f8d1053768..132fa896c8 100644 --- a/pkg/controller/elasticsearch/settings/config_volume.go +++ b/pkg/controller/elasticsearch/settings/config_volume.go @@ -13,7 +13,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/common/volume" @@ -77,7 +77,7 @@ func GetESConfigSecret(client k8s.Client, namespace string, ssetName string) (co return secret, nil } -func ConfigSecret(es v1alpha1.Elasticsearch, ssetName string, configData []byte) corev1.Secret { +func ConfigSecret(es v1beta1.Elasticsearch, ssetName string, configData []byte) corev1.Secret { return corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Namespace: es.Namespace, @@ -91,7 +91,7 @@ func ConfigSecret(es v1alpha1.Elasticsearch, ssetName string, configData []byte) } // ReconcileConfig ensures the ES config for the pod is set in the apiserver. -func ReconcileConfig(client k8s.Client, es v1alpha1.Elasticsearch, ssetName string, config CanonicalConfig) error { +func ReconcileConfig(client k8s.Client, es v1beta1.Elasticsearch, ssetName string, config CanonicalConfig) error { rendered, err := config.Render() if err != nil { return err diff --git a/pkg/controller/elasticsearch/settings/config_volume_test.go b/pkg/controller/elasticsearch/settings/config_volume_test.go index c8ef2d2474..d2ac8037a4 100644 --- a/pkg/controller/elasticsearch/settings/config_volume_test.go +++ b/pkg/controller/elasticsearch/settings/config_volume_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -93,9 +93,9 @@ func TestGetESConfigContent(t *testing.T) { } func TestReconcileConfig(t *testing.T) { - err := v1alpha1.AddToScheme(scheme.Scheme) + err := v1beta1.AddToScheme(scheme.Scheme) assert.NoError(t, err) - es := v1alpha1.Elasticsearch{ + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "cluster", @@ -121,7 +121,7 @@ func TestReconcileConfig(t *testing.T) { tests := []struct { name string client k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch ssetName string config CanonicalConfig wantErr bool diff --git a/pkg/controller/elasticsearch/settings/masters.go b/pkg/controller/elasticsearch/settings/masters.go index e63be40d64..087f0b5389 100644 --- a/pkg/controller/elasticsearch/settings/masters.go +++ b/pkg/controller/elasticsearch/settings/masters.go @@ -9,7 +9,7 @@ import ( "reflect" "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" @@ -36,7 +36,7 @@ func Quorum(nMasters int) int { func UpdateSeedHostsConfigMap( c k8s.Client, scheme *runtime.Scheme, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, pods []corev1.Pod, ) error { // Get the masters from the pods diff --git a/pkg/controller/elasticsearch/settings/masters_test.go b/pkg/controller/elasticsearch/settings/masters_test.go index fa5c991eb2..3215d554bd 100644 --- a/pkg/controller/elasticsearch/settings/masters_test.go +++ b/pkg/controller/elasticsearch/settings/masters_test.go @@ -7,7 +7,7 @@ package settings import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/volume" @@ -41,8 +41,8 @@ func newPodWithIP(name, ip string, master bool) corev1.Pod { } func TestUpdateSeedHostsConfigMap(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) - es := v1alpha1.Elasticsearch{ + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "es1", Namespace: "ns1", @@ -51,7 +51,7 @@ func TestUpdateSeedHostsConfigMap(t *testing.T) { type args struct { c k8s.Client scheme *runtime.Scheme - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch pods []corev1.Pod } tests := []struct { diff --git a/pkg/controller/elasticsearch/settings/merged_config.go b/pkg/controller/elasticsearch/settings/merged_config.go index e49a3a7989..5d2f67c661 100644 --- a/pkg/controller/elasticsearch/settings/merged_config.go +++ b/pkg/controller/elasticsearch/settings/merged_config.go @@ -7,7 +7,7 @@ package settings import ( "path" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" @@ -20,8 +20,8 @@ import ( func NewMergedESConfig( clusterName string, ver version.Version, - httpConfig v1alpha1.HTTPConfig, - userConfig v1alpha1.Config, + httpConfig v1beta1.HTTPConfig, + userConfig v1beta1.Config, certResources *escerts.CertificateResources, ) (CanonicalConfig, error) { config, err := common.NewCanonicalConfigFrom(userConfig.Data) @@ -58,7 +58,7 @@ func baseConfig(clusterName string) *CanonicalConfig { } // xpackConfig returns the configuration bit related to XPack settings -func xpackConfig(ver version.Version, httpCfg v1alpha1.HTTPConfig, certResources *escerts.CertificateResources) *CanonicalConfig { +func xpackConfig(ver version.Version, httpCfg v1beta1.HTTPConfig, certResources *escerts.CertificateResources) *CanonicalConfig { // enable x-pack security, including TLS cfg := map[string]interface{}{ // x-pack security general settings diff --git a/pkg/controller/elasticsearch/settings/merged_config_test.go b/pkg/controller/elasticsearch/settings/merged_config_test.go index a9658ad705..ac65cc2d3a 100644 --- a/pkg/controller/elasticsearch/settings/merged_config_test.go +++ b/pkg/controller/elasticsearch/settings/merged_config_test.go @@ -7,7 +7,7 @@ package settings import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/certificates" "github.com/stretchr/testify/require" @@ -104,8 +104,8 @@ func TestNewMergedESConfig(t *testing.T) { cfg, err := NewMergedESConfig( "clusterName", *ver, - v1alpha1.HTTPConfig{}, - v1alpha1.Config{Data: tt.cfgData}, + v1beta1.HTTPConfig{}, + v1beta1.Config{Data: tt.cfgData}, &certificates.CertificateResources{}, ) require.NoError(t, err) diff --git a/pkg/controller/elasticsearch/sset/pod.go b/pkg/controller/elasticsearch/sset/pod.go index 9d7c6cbda2..88d1611e13 100644 --- a/pkg/controller/elasticsearch/sset/pod.go +++ b/pkg/controller/elasticsearch/sset/pod.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/pkg/utils/stringsutil" @@ -52,7 +52,7 @@ func GetActualPodsForStatefulSet(c k8s.Client, sset appsv1.StatefulSet) ([]corev } // GetActualPodsForCluster return the existing pods associated to this cluster. -func GetActualPodsForCluster(c k8s.Client, es v1alpha1.Elasticsearch) ([]corev1.Pod, error) { +func GetActualPodsForCluster(c k8s.Client, es v1beta1.Elasticsearch) ([]corev1.Pod, error) { var pods corev1.PodList ns := client.InNamespace(es.Namespace) @@ -66,7 +66,7 @@ func GetActualPodsForCluster(c k8s.Client, es v1alpha1.Elasticsearch) ([]corev1. } // GetActualMastersForCluster returns the list of existing master-eligible pods for the cluster. -func GetActualMastersForCluster(c k8s.Client, es v1alpha1.Elasticsearch) ([]corev1.Pod, error) { +func GetActualMastersForCluster(c k8s.Client, es v1beta1.Elasticsearch) ([]corev1.Pod, error) { pods, err := GetActualPodsForCluster(c, es) if err != nil { return nil, err diff --git a/pkg/controller/elasticsearch/sset/reconcile.go b/pkg/controller/elasticsearch/sset/reconcile.go index 8dabacd105..f04b62c127 100644 --- a/pkg/controller/elasticsearch/sset/reconcile.go +++ b/pkg/controller/elasticsearch/sset/reconcile.go @@ -5,7 +5,7 @@ package sset import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" @@ -15,7 +15,7 @@ import ( ) // ReconcileStatefulSet creates or updates the expected StatefulSet. -func ReconcileStatefulSet(c k8s.Client, scheme *runtime.Scheme, es v1alpha1.Elasticsearch, expected appsv1.StatefulSet, expectations *expectations.Expectations) (appsv1.StatefulSet, error) { +func ReconcileStatefulSet(c k8s.Client, scheme *runtime.Scheme, es v1beta1.Elasticsearch, expected appsv1.StatefulSet, expectations *expectations.Expectations) (appsv1.StatefulSet, error) { var reconciled appsv1.StatefulSet err := reconciler.ReconcileResource(reconciler.Params{ Client: c, diff --git a/pkg/controller/elasticsearch/sset/reconcile_test.go b/pkg/controller/elasticsearch/sset/reconcile_test.go index ef849dfbe8..09def219fc 100644 --- a/pkg/controller/elasticsearch/sset/reconcile_test.go +++ b/pkg/controller/elasticsearch/sset/reconcile_test.go @@ -17,15 +17,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/expectations" "github.com/elastic/cloud-on-k8s/pkg/controller/common/hash" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) func TestReconcileStatefulSet(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) - es := v1alpha1.Elasticsearch{ + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "es", diff --git a/pkg/controller/elasticsearch/user/reconciler.go b/pkg/controller/elasticsearch/user/reconciler.go index eb4c990625..68eeeee6f4 100644 --- a/pkg/controller/elasticsearch/user/reconciler.go +++ b/pkg/controller/elasticsearch/user/reconciler.go @@ -5,7 +5,7 @@ package user import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -18,7 +18,7 @@ import ( func ReconcileUserCredentialsSecret( c k8s.Client, scheme *runtime.Scheme, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, creds UserCredentials, ) error { expected := creds.Secret() @@ -74,7 +74,7 @@ func aggregateAllUsers(customUsers corev1.SecretList, defaultUsers ...ClearTextC func ReconcileUsers( c k8s.Client, scheme *runtime.Scheme, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, ) (*InternalUsers, error) { nsn := k8s.ExtractNamespacedName(&es) diff --git a/pkg/controller/elasticsearch/validation/upgrade_checks_test.go b/pkg/controller/elasticsearch/validation/upgrade_checks_test.go index 5532981b59..ce81166870 100644 --- a/pkg/controller/elasticsearch/validation/upgrade_checks_test.go +++ b/pkg/controller/elasticsearch/validation/upgrade_checks_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/controller/elasticsearch/validation/validation.go b/pkg/controller/elasticsearch/validation/validation.go index 9852d58bf9..b980f73722 100644 --- a/pkg/controller/elasticsearch/validation/validation.go +++ b/pkg/controller/elasticsearch/validation/validation.go @@ -5,7 +5,7 @@ package validation import ( - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" pkgerrors "github.com/pkg/errors" diff --git a/pkg/controller/elasticsearch/validation/validation_test.go b/pkg/controller/elasticsearch/validation/validation_test.go index 87e43b177e..49f9091e05 100644 --- a/pkg/controller/elasticsearch/validation/validation_test.go +++ b/pkg/controller/elasticsearch/validation/validation_test.go @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - common "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + common "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/settings" ) diff --git a/pkg/controller/elasticsearch/validation/validations.go b/pkg/controller/elasticsearch/validation/validations.go index 864f1d7f5d..f9d0d6f35e 100644 --- a/pkg/controller/elasticsearch/validation/validations.go +++ b/pkg/controller/elasticsearch/validation/validations.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" @@ -57,7 +57,7 @@ func supportedVersion(ctx Context) validation.Result { func hasMaster(ctx Context) validation.Result { var hasMaster bool for _, t := range ctx.Proposed.Elasticsearch.Spec.Nodes { - cfg, err := v1alpha1.UnpackConfig(t.Config) + cfg, err := v1beta1.UnpackConfig(t.Config) if err != nil { return validation.Result{Reason: cfgInvalidMsg} } @@ -165,7 +165,7 @@ func pvcModification(ctx Context) validation.Result { return validation.OK } -func getNode(name string, es v1alpha1.Elasticsearch) *v1alpha1.NodeSpec { +func getNode(name string, es v1beta1.Elasticsearch) *v1beta1.NodeSpec { for i := range es.Spec.Nodes { if es.Spec.Nodes[i].Name == name { return &es.Spec.Nodes[i] diff --git a/pkg/controller/elasticsearch/validation/validations_test.go b/pkg/controller/elasticsearch/validation/validations_test.go index 38ae4ed256..4964ff1075 100644 --- a/pkg/controller/elasticsearch/validation/validations_test.go +++ b/pkg/controller/elasticsearch/validation/validations_test.go @@ -14,9 +14,9 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - common "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + common "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common_name "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" @@ -27,7 +27,7 @@ import ( func Test_hasMaster(t *testing.T) { failedValidation := validation.Result{Allowed: false, Reason: masterRequiredMsg} type args struct { - esCluster v1alpha1.Elasticsearch + esCluster v1beta1.Elasticsearch } tests := []struct { name string @@ -44,17 +44,17 @@ func Test_hasMaster(t *testing.T) { { name: "topology but no master", args: args{ - esCluster: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + esCluster: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.0.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Config: &common.Config{ Data: map[string]interface{}{ - v1alpha1.NodeMaster: "false", - v1alpha1.NodeData: "false", - v1alpha1.NodeIngest: "false", - v1alpha1.NodeML: "false", + v1beta1.NodeMaster: "false", + v1beta1.NodeData: "false", + v1beta1.NodeIngest: "false", + v1beta1.NodeML: "false", }, }, }, @@ -67,17 +67,17 @@ func Test_hasMaster(t *testing.T) { { name: "master but zero sized", args: args{ - esCluster: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + esCluster: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.0.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Config: &common.Config{ Data: map[string]interface{}{ - v1alpha1.NodeMaster: "true", - v1alpha1.NodeData: "false", - v1alpha1.NodeIngest: "false", - v1alpha1.NodeML: "false", + v1beta1.NodeMaster: "true", + v1beta1.NodeData: "false", + v1beta1.NodeIngest: "false", + v1beta1.NodeML: "false", }, }, }, @@ -90,17 +90,17 @@ func Test_hasMaster(t *testing.T) { { name: "has master", args: args{ - esCluster: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + esCluster: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.0.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Config: &common.Config{ Data: map[string]interface{}{ - v1alpha1.NodeMaster: "true", - v1alpha1.NodeData: "false", - v1alpha1.NodeIngest: "false", - v1alpha1.NodeML: "false", + v1beta1.NodeMaster: "true", + v1beta1.NodeData: "false", + v1beta1.NodeIngest: "false", + v1beta1.NodeML: "false", }, }, NodeCount: 1, @@ -450,17 +450,17 @@ func Test_pvcModified(t *testing.T) { current := getEsCluster() tests := []struct { name string - current *v1alpha1.Elasticsearch - proposed v1alpha1.Elasticsearch + current *v1beta1.Elasticsearch + proposed v1beta1.Elasticsearch want validation.Result }{ { name: "resize fails", current: current, - proposed: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + proposed: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "master", VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ @@ -487,10 +487,10 @@ func Test_pvcModified(t *testing.T) { { name: "same size accepted", current: current, - proposed: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + proposed: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "master", VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ @@ -517,10 +517,10 @@ func Test_pvcModified(t *testing.T) { { name: "additional PVC fails", current: current, - proposed: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + proposed: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "master", VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ @@ -559,10 +559,10 @@ func Test_pvcModified(t *testing.T) { { name: "name change rejected", current: current, - proposed: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + proposed: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "master", VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ @@ -589,10 +589,10 @@ func Test_pvcModified(t *testing.T) { { name: "add new node set accepted", current: current, - proposed: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ + proposed: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "master", VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ @@ -651,11 +651,11 @@ func Test_pvcModified(t *testing.T) { } // getEsCluster returns a ES cluster test fixture -func getEsCluster() *v1alpha1.Elasticsearch { - return &v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{ +func getEsCluster() *v1beta1.Elasticsearch { + return &v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.2.0", - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "master", VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ diff --git a/pkg/controller/elasticsearch/version/zen1/compatibility.go b/pkg/controller/elasticsearch/version/zen1/compatibility.go index c1a1b2a599..6d4af0a60a 100644 --- a/pkg/controller/elasticsearch/version/zen1/compatibility.go +++ b/pkg/controller/elasticsearch/version/zen1/compatibility.go @@ -5,7 +5,7 @@ package zen1 import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" @@ -30,7 +30,7 @@ func IsCompatibleWithZen1(statefulSet appsv1.StatefulSet) bool { func AtLeastOneNodeCompatibleWithZen1( statefulSets sset.StatefulSetList, c k8s.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, ) (bool, error) { actualMasters, err := sset.GetActualMastersForCluster(c, es) if err != nil { diff --git a/pkg/controller/elasticsearch/version/zen1/compatibility_test.go b/pkg/controller/elasticsearch/version/zen1/compatibility_test.go index e500051eef..6bca5cc461 100644 --- a/pkg/controller/elasticsearch/version/zen1/compatibility_test.go +++ b/pkg/controller/elasticsearch/version/zen1/compatibility_test.go @@ -7,7 +7,7 @@ package zen1 import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -28,7 +28,7 @@ func createStatefulSetWithVersion(version string) appsv1.StatefulSet { }}} } -var testES = v1alpha1.Elasticsearch{ +var testES = v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "es1", Namespace: "default", diff --git a/pkg/controller/elasticsearch/version/zen1/minimum_masters.go b/pkg/controller/elasticsearch/version/zen1/minimum_masters.go index 92927ab9c1..29de4743f0 100644 --- a/pkg/controller/elasticsearch/version/zen1/minimum_masters.go +++ b/pkg/controller/elasticsearch/version/zen1/minimum_masters.go @@ -8,7 +8,7 @@ import ( "context" "strconv" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" @@ -32,7 +32,7 @@ const ( // This function should not be called unless all the expectations are met. func SetupMinimumMasterNodesConfig( c k8s.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, nodeSpecResources nodespec.ResourcesList, ) error { // Check if we have at least one Zen1 compatible pod or StatefulSet in flight. @@ -87,7 +87,7 @@ func SetupMinimumMasterNodesConfig( // It returns true if this should be retried later (re-queued). func UpdateMinimumMasterNodes( c k8s.Client, - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, esClient client.Client, actualStatefulSets sset.StatefulSetList, ) (bool, error) { @@ -132,7 +132,7 @@ func UpdateMinimumMasterNodes( // to the given value, if the cluster is using zen1. // Should only be called it there are some Zen1 compatible masters func UpdateMinimumMasterNodesTo( - es v1alpha1.Elasticsearch, + es v1beta1.Elasticsearch, c k8s.Client, esClient client.Client, minimumMasterNodes int, @@ -157,7 +157,7 @@ func UpdateMinimumMasterNodesTo( return annotateWithMinimumMasterNodes(c, es, minimumMasterNodes) } -func minimumMasterNodesFromAnnotation(es v1alpha1.Elasticsearch) int { +func minimumMasterNodesFromAnnotation(es v1beta1.Elasticsearch) int { annotationStr, set := es.Annotations[Zen1MiniumMasterNodesAnnotationName] if !set { return 0 @@ -170,7 +170,7 @@ func minimumMasterNodesFromAnnotation(es v1alpha1.Elasticsearch) int { return mmn } -func annotateWithMinimumMasterNodes(c k8s.Client, es v1alpha1.Elasticsearch, minimumMasterNodes int) error { +func annotateWithMinimumMasterNodes(c k8s.Client, es v1beta1.Elasticsearch, minimumMasterNodes int) error { if es.Annotations == nil { es.Annotations = make(map[string]string) } diff --git a/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go b/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go index 9ecb770518..2fe30330a4 100644 --- a/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go +++ b/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go @@ -8,7 +8,7 @@ import ( "context" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/scheme" settings2 "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" @@ -151,7 +151,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { wantRequeue bool wantCalledWith int c k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch name string actualStatefulSets sset.StatefulSetList }{ @@ -165,7 +165,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { name: "correct mmn already set in ES annotation", c: k8s.WrapClient(fake.NewFakeClient(&podsReady3[0], &podsReady3[1], &podsReady3[2])), actualStatefulSets: sset.StatefulSetList{ssetSample}, - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: esName, Namespace: ns, @@ -180,7 +180,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { name: "mmn should be updated, it's different in the ES annotation", c: k8s.WrapClient(fake.NewFakeClient(&podsReady3[0], &podsReady3[1], &podsReady3[2])), actualStatefulSets: sset.StatefulSetList{ssetSample}, - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: esName, Namespace: ns, @@ -196,7 +196,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { name: "mmn should be updated, it isn't set in the ES annotation", c: k8s.WrapClient(fake.NewFakeClient(&podsReady3[0], &podsReady3[1], &podsReady3[2])), actualStatefulSets: sset.StatefulSetList{ssetSample}, - es: v1alpha1.Elasticsearch{ObjectMeta: k8s.ToObjectMeta(nsn)}, + es: v1beta1.Elasticsearch{ObjectMeta: k8s.ToObjectMeta(nsn)}, wantCalled: true, wantCalledWith: 2, }, @@ -204,7 +204,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { name: "cannot update since not enough masters available", c: k8s.WrapClient(fake.NewFakeClient(&podsReady1[0], &podsReady1[1], &podsReady1[2])), actualStatefulSets: sset.StatefulSetList{ssetSample}, - es: v1alpha1.Elasticsearch{ObjectMeta: k8s.ToObjectMeta(nsn)}, + es: v1beta1.Elasticsearch{ObjectMeta: k8s.ToObjectMeta(nsn)}, wantCalled: false, wantRequeue: true, }, diff --git a/pkg/controller/elasticsearch/version/zen2/compatibility.go b/pkg/controller/elasticsearch/version/zen2/compatibility.go index a9257d7fc9..9cb1e1ba18 100644 --- a/pkg/controller/elasticsearch/version/zen2/compatibility.go +++ b/pkg/controller/elasticsearch/version/zen2/compatibility.go @@ -5,7 +5,7 @@ package zen2 import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" @@ -26,7 +26,7 @@ func IsCompatibleWithZen2(statefulSet appsv1.StatefulSet) bool { // AllMastersCompatibleWithZen2 returns true if all master nodes in the given cluster can use zen2 APIs. // During a v6 -> v7 rolling upgrade, we can only call zen2 APIs once the current master is using v7, // which would happen only if there is no more v6 master-eligible nodes in the cluster. -func AllMastersCompatibleWithZen2(c k8s.Client, es v1alpha1.Elasticsearch) (bool, error) { +func AllMastersCompatibleWithZen2(c k8s.Client, es v1beta1.Elasticsearch) (bool, error) { masters, err := sset.GetActualMastersForCluster(c, es) if err != nil { return false, err @@ -47,7 +47,7 @@ func AllMastersCompatibleWithZen2(c k8s.Client, es v1alpha1.Elasticsearch) (bool } // IsInitialZen2Upgrade detects whether this is an initial upgrade of a non zen2 cluster (6.x) to a zen2 compatible version (7.x +) -func IsInitialZen2Upgrade(c k8s.Client, es v1alpha1.Elasticsearch) (bool, error) { +func IsInitialZen2Upgrade(c k8s.Client, es v1beta1.Elasticsearch) (bool, error) { newVersion, err := version.Parse(es.Spec.Version) if err != nil || !versionCompatibleWithZen2(*newVersion) { return false, err diff --git a/pkg/controller/elasticsearch/version/zen2/compatibility_test.go b/pkg/controller/elasticsearch/version/zen2/compatibility_test.go index 4e3858a08e..5c89d61180 100644 --- a/pkg/controller/elasticsearch/version/zen2/compatibility_test.go +++ b/pkg/controller/elasticsearch/version/zen2/compatibility_test.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -62,7 +62,7 @@ func TestIsCompatibleWithZen2(t *testing.T) { } func TestAllMastersCompatibleWithZen2(t *testing.T) { - es := v1alpha1.Elasticsearch{ + es := v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", Name: "cluster", @@ -119,7 +119,7 @@ func TestAllMastersCompatibleWithZen2(t *testing.T) { func TestIsInitialZen2Upgrade(t *testing.T) { type args struct { c k8s.Client - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch } tests := []struct { name string @@ -131,7 +131,7 @@ func TestIsInitialZen2Upgrade(t *testing.T) { name: "new 7.x", args: args{ c: k8s.WrapClient(fake.NewFakeClient()), - es: v1alpha1.Elasticsearch{Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}}, + es: v1beta1.Elasticsearch{Spec: v1beta1.ElasticsearchSpec{Version: "7.3.0"}}, }, want: true, wantErr: false, @@ -147,8 +147,8 @@ func TestIsInitialZen2Upgrade(t *testing.T) { Version: "6.8.0", Master: true, }.BuildPtr())), - es: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}, + es: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{Version: "7.3.0"}, }, }, want: true, @@ -165,12 +165,12 @@ func TestIsInitialZen2Upgrade(t *testing.T) { Version: "7.1.0", Master: true, }.BuildPtr())), - es: v1alpha1.Elasticsearch{ + es: v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "es", Namespace: "default", }, - Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}, + Spec: v1beta1.ElasticsearchSpec{Version: "7.3.0"}, }, }, want: false, @@ -187,8 +187,8 @@ func TestIsInitialZen2Upgrade(t *testing.T) { Version: "6.8.0", Master: true, }.BuildPtr())), - es: v1alpha1.Elasticsearch{ - Spec: v1alpha1.ElasticsearchSpec{Version: "6.8.1"}, + es: v1beta1.Elasticsearch{ + Spec: v1beta1.ElasticsearchSpec{Version: "6.8.1"}, }, }, want: false, diff --git a/pkg/controller/elasticsearch/version/zen2/voting_exclusions.go b/pkg/controller/elasticsearch/version/zen2/voting_exclusions.go index 2e1eaef37a..7b65642e73 100644 --- a/pkg/controller/elasticsearch/version/zen2/voting_exclusions.go +++ b/pkg/controller/elasticsearch/version/zen2/voting_exclusions.go @@ -9,7 +9,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -20,7 +20,7 @@ var ( ) // AddToVotingConfigExclusions adds the given node names to exclude from voting config exclusions. -func AddToVotingConfigExclusions(c k8s.Client, esClient client.Client, es v1alpha1.Elasticsearch, excludeNodes []string) error { +func AddToVotingConfigExclusions(c k8s.Client, esClient client.Client, es v1beta1.Elasticsearch, excludeNodes []string) error { compatible, err := AllMastersCompatibleWithZen2(c, es) if err != nil { return err @@ -53,7 +53,7 @@ func canClearVotingConfigExclusions(c k8s.Client, actualStatefulSets sset.Statef // ClearVotingConfigExclusions resets the voting config exclusions if all excluded nodes are properly removed. // It returns true if this should be retried later (re-queued). -func ClearVotingConfigExclusions(es v1alpha1.Elasticsearch, c k8s.Client, esClient client.Client, actualStatefulSets sset.StatefulSetList) (bool, error) { +func ClearVotingConfigExclusions(es v1beta1.Elasticsearch, c k8s.Client, esClient client.Client, actualStatefulSets sset.StatefulSetList) (bool, error) { compatible, err := AllMastersCompatibleWithZen2(c, es) if err != nil { return false, err diff --git a/pkg/controller/elasticsearch/version/zen2/voting_exclusions_test.go b/pkg/controller/elasticsearch/version/zen2/voting_exclusions_test.go index 8070d43c82..27dce15d43 100644 --- a/pkg/controller/elasticsearch/version/zen2/voting_exclusions_test.go +++ b/pkg/controller/elasticsearch/version/zen2/voting_exclusions_test.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -32,7 +32,7 @@ func (f *fakeESClient) DeleteVotingConfigExclusions(ctx context.Context, waitFor func Test_ClearVotingConfigExclusions(t *testing.T) { // dummy statefulset with 3 pods statefulSet3rep := sset.TestSset{Name: "nodes", Version: "7.2.0", Replicas: 3, Master: true, Data: true}.Build() - es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "es", Namespace: statefulSet3rep.Namespace}} + es := v1beta1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "es", Namespace: statefulSet3rep.Namespace}} pods := make([]corev1.Pod, 0, *statefulSet3rep.Spec.Replicas) for _, podName := range sset.PodNames(statefulSet3rep) { pods = append(pods, sset.TestPod{ diff --git a/pkg/controller/kibana/certificates/reconcile.go b/pkg/controller/kibana/certificates/reconcile.go index 1921d5aa73..95c9ef746d 100644 --- a/pkg/controller/kibana/certificates/reconcile.go +++ b/pkg/controller/kibana/certificates/reconcile.go @@ -7,7 +7,7 @@ package certificates import ( "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" "github.com/elastic/cloud-on-k8s/pkg/controller/common/driver" @@ -20,7 +20,7 @@ import ( func Reconcile( d driver.Interface, - kb v1alpha1.Kibana, + kb v1beta1.Kibana, services []coverv1.Service, rotation certificates.RotationParams, ) *reconciler.Results { diff --git a/pkg/controller/kibana/config/reconciler.go b/pkg/controller/kibana/config/reconciler.go index 535e4d9575..b838f1f826 100644 --- a/pkg/controller/kibana/config/reconciler.go +++ b/pkg/controller/kibana/config/reconciler.go @@ -8,7 +8,7 @@ import ( "reflect" "github.com/elastic/cloud-on-k8s/pkg/about" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -21,7 +21,7 @@ import ( // This managed secret is mounted into each pod of the Kibana deployment. func ReconcileConfigSecret( client k8s.Client, - kb v1alpha1.Kibana, + kb v1beta1.Kibana, kbSettings CanonicalConfig, operatorInfo about.OperatorInfo, ) error { diff --git a/pkg/controller/kibana/config/reconciler_test.go b/pkg/controller/kibana/config/reconciler_test.go index 2b8e18f6a2..f537216e40 100644 --- a/pkg/controller/kibana/config/reconciler_test.go +++ b/pkg/controller/kibana/config/reconciler_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/elastic/cloud-on-k8s/pkg/about" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -22,7 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) -var defaultKibana = v1alpha1.Kibana{ +var defaultKibana = v1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test-ns", Name: "test", @@ -32,7 +32,7 @@ var defaultKibana = v1alpha1.Kibana{ func TestReconcileConfigSecret(t *testing.T) { type args struct { initialObjects []runtime.Object - kb v1alpha1.Kibana + kb v1beta1.Kibana } tests := []struct { name string @@ -43,7 +43,7 @@ func TestReconcileConfigSecret(t *testing.T) { name: "config secret should be created", args: args{ kb: defaultKibana, - initialObjects: []runtime.Object{&v1alpha1.Kibana{ + initialObjects: []runtime.Object{&v1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test-ns", @@ -105,7 +105,7 @@ func TestReconcileConfigSecret(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { sc := scheme.Scheme - if err := v1alpha1.SchemeBuilder.AddToScheme(sc); err != nil { + if err := v1beta1.SchemeBuilder.AddToScheme(sc); err != nil { assert.Fail(t, "failed to build custom scheme") } k8sClient := k8s.WrapClient(fake.NewFakeClientWithScheme(sc, tt.args.initialObjects...)) diff --git a/pkg/controller/kibana/config/secret_volume.go b/pkg/controller/kibana/config/secret_volume.go index 0347c74595..9df24f347f 100644 --- a/pkg/controller/kibana/config/secret_volume.go +++ b/pkg/controller/kibana/config/secret_volume.go @@ -5,7 +5,7 @@ package config import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/volume" ) @@ -16,7 +16,7 @@ const ( ) // SecretVolume returns a SecretVolume to hold the Kibana config of the given Kibana resource. -func SecretVolume(kb v1alpha1.Kibana) volume.SecretVolume { +func SecretVolume(kb v1beta1.Kibana) volume.SecretVolume { return volume.NewSecretVolumeWithMountPath( SecretName(kb), VolumeName, @@ -25,6 +25,6 @@ func SecretVolume(kb v1alpha1.Kibana) volume.SecretVolume { } // SecretName is the name of the secret that holds the Kibana config for the given Kibana resource. -func SecretName(kb v1alpha1.Kibana) string { +func SecretName(kb v1beta1.Kibana) string { return kb.Name + "-kb-" + VolumeName } diff --git a/pkg/controller/kibana/config/settings.go b/pkg/controller/kibana/config/settings.go index 9aa1345eb8..2063315dce 100644 --- a/pkg/controller/kibana/config/settings.go +++ b/pkg/controller/kibana/config/settings.go @@ -7,8 +7,8 @@ package config import ( "path" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/association" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" @@ -27,10 +27,10 @@ type CanonicalConfig struct { } // NewConfigSettings returns the Kibana configuration settings for the given Kibana resource. -func NewConfigSettings(client k8s.Client, kb v1alpha1.Kibana) (CanonicalConfig, error) { +func NewConfigSettings(client k8s.Client, kb v1beta1.Kibana) (CanonicalConfig, error) { specConfig := kb.Spec.Config if specConfig == nil { - specConfig = &commonv1alpha1.Config{} + specConfig = &commonv1beta1.Config{} } userSettings, err := settings.NewCanonicalConfigFrom(specConfig.Data) @@ -64,7 +64,7 @@ func NewConfigSettings(client k8s.Client, kb v1alpha1.Kibana) (CanonicalConfig, return CanonicalConfig{cfg}, nil } -func baseSettings(kb v1alpha1.Kibana) map[string]interface{} { +func baseSettings(kb v1beta1.Kibana) map[string]interface{} { return map[string]interface{}{ ServerName: kb.Name, ServerHost: "0", @@ -73,7 +73,7 @@ func baseSettings(kb v1alpha1.Kibana) map[string]interface{} { } } -func kibanaTLSSettings(kb v1alpha1.Kibana) map[string]interface{} { +func kibanaTLSSettings(kb v1beta1.Kibana) map[string]interface{} { if !kb.Spec.HTTP.TLS.Enabled() { return nil } @@ -84,7 +84,7 @@ func kibanaTLSSettings(kb v1alpha1.Kibana) map[string]interface{} { } } -func elasticsearchTLSSettings(kb v1alpha1.Kibana) map[string]interface{} { +func elasticsearchTLSSettings(kb v1beta1.Kibana) map[string]interface{} { cfg := map[string]interface{}{ ElasticsearchSslVerificationMode: "certificate", } diff --git a/pkg/controller/kibana/config/settings_test.go b/pkg/controller/kibana/config/settings_test.go index 55febad726..fcc2789802 100644 --- a/pkg/controller/kibana/config/settings_test.go +++ b/pkg/controller/kibana/config/settings_test.go @@ -7,8 +7,8 @@ package config import ( "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ucfg "github.com/elastic/go-ucfg" @@ -44,7 +44,7 @@ xpack: func TestNewConfigSettings(t *testing.T) { type args struct { client k8s.Client - kb func() v1alpha1.Kibana + kb func() v1beta1.Kibana } tests := []struct { name string @@ -62,12 +62,12 @@ func TestNewConfigSettings(t *testing.T) { { name: "without TLS", args: args{ - kb: func() v1alpha1.Kibana { + kb: func() v1beta1.Kibana { kb := mkKibana() - kb.Spec = v1alpha1.KibanaSpec{ - HTTP: commonv1alpha1.HTTPConfig{ - TLS: commonv1alpha1.TLSOptions{ - SelfSignedCertificate: &commonv1alpha1.SelfSignedCertificate{ + kb.Spec = v1beta1.KibanaSpec{ + HTTP: commonv1beta1.HTTPConfig{ + TLS: commonv1beta1.TLSOptions{ + SelfSignedCertificate: &commonv1beta1.SelfSignedCertificate{ Disabled: true, }, }, @@ -91,9 +91,9 @@ func TestNewConfigSettings(t *testing.T) { { name: "without Elasticsearch CA", args: args{ - kb: func() v1alpha1.Kibana { + kb: func() v1beta1.Kibana { kb := mkKibana() - kb.SetAssociationConf(&commonv1alpha1.AssociationConf{CACertProvided: false}) + kb.SetAssociationConf(&commonv1beta1.AssociationConf{CACertProvided: false}) return kb }, }, @@ -112,10 +112,10 @@ func TestNewConfigSettings(t *testing.T) { { name: "with user config", args: args{ - kb: func() v1alpha1.Kibana { + kb: func() v1beta1.Kibana { kb := mkKibana() - kb.Spec = v1alpha1.KibanaSpec{ - Config: &commonv1alpha1.Config{ + kb.Spec = v1beta1.KibanaSpec{ + Config: &commonv1beta1.Config{ Data: map[string]interface{}{ "foo": "bar", }, @@ -140,7 +140,7 @@ func TestNewConfigSettings(t *testing.T) { require.NoError(t, got.Unpack(&gotCfg)) // convert "want" into something comparable - cfg, err := uyaml.NewConfig(tt.want, commonv1alpha1.CfgOptions...) + cfg, err := uyaml.NewConfig(tt.want, commonv1beta1.CfgOptions...) require.NoError(t, err) var wantCfg map[string]interface{} require.NoError(t, cfg.Unpack(&wantCfg)) @@ -151,8 +151,8 @@ func TestNewConfigSettings(t *testing.T) { } } -func mkKibana() v1alpha1.Kibana { - kb := v1alpha1.Kibana{} - kb.SetAssociationConf(&commonv1alpha1.AssociationConf{CACertProvided: true}) +func mkKibana() v1beta1.Kibana { + kb := v1beta1.Kibana{} + kb.SetAssociationConf(&commonv1beta1.AssociationConf{CACertProvided: true}) return kb } diff --git a/pkg/controller/kibana/driver.go b/pkg/controller/kibana/driver.go index 1213cf9597..4c2f399873 100644 --- a/pkg/controller/kibana/driver.go +++ b/pkg/controller/kibana/driver.go @@ -8,7 +8,7 @@ import ( "crypto/sha256" "fmt" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" diff --git a/pkg/controller/kibana/driver_test.go b/pkg/controller/kibana/driver_test.go index c5bd30f9c0..93235d4197 100644 --- a/pkg/controller/kibana/driver_test.go +++ b/pkg/controller/kibana/driver_test.go @@ -7,8 +7,8 @@ package kibana import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" "github.com/elastic/cloud-on-k8s/pkg/controller/common/deployment" @@ -73,7 +73,7 @@ func TestDriverDeploymentParams(t *testing.T) { args: args{ kb: func() *kbtype.Kibana { kb := kibanaFixture() - kb.Spec.HTTP.TLS.SelfSignedCertificate = &v1alpha1.SelfSignedCertificate{ + kb.Spec.HTTP.TLS.SelfSignedCertificate = &v1beta1.SelfSignedCertificate{ Disabled: true, } return kb @@ -334,7 +334,7 @@ func kibanaFixture() *kbtype.Kibana { }, } - kbFixture.SetAssociationConf(&v1alpha1.AssociationConf{ + kbFixture.SetAssociationConf(&v1beta1.AssociationConf{ AuthSecretName: "test-auth", AuthSecretKey: "kibana-user", CASecretName: "es-ca-secret", diff --git a/pkg/controller/kibana/es/secret.go b/pkg/controller/kibana/es/secret.go index 85d9f86997..9c5a8577e2 100644 --- a/pkg/controller/kibana/es/secret.go +++ b/pkg/controller/kibana/es/secret.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/volume" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) @@ -16,7 +16,7 @@ import ( var eSCertsVolumeMountPath = "/usr/share/kibana/config/elasticsearch-certs" // CaCertSecretVolume returns a SecretVolume to hold the Elasticsearch CA certs for the given Kibana resource. -func CaCertSecretVolume(kb v1alpha1.Kibana) volume.SecretVolume { +func CaCertSecretVolume(kb v1beta1.Kibana) volume.SecretVolume { // TODO: this is a little ugly as it reaches into the ES controller bits return volume.NewSecretVolumeWithMountPath( kb.AssociationConf().GetCASecretName(), @@ -26,7 +26,7 @@ func CaCertSecretVolume(kb v1alpha1.Kibana) volume.SecretVolume { } // GetAuthSecret returns the Elasticsearch auth secret for the given Kibana resource. -func GetAuthSecret(client k8s.Client, kb v1alpha1.Kibana) (*corev1.Secret, error) { +func GetAuthSecret(client k8s.Client, kb v1beta1.Kibana) (*corev1.Secret, error) { esAuthSecret := types.NamespacedName{ Name: kb.AssociationConf().GetAuthSecretName(), Namespace: kb.Namespace, diff --git a/pkg/controller/kibana/kibana_controller.go b/pkg/controller/kibana/kibana_controller.go index 07ba768530..2babe585eb 100644 --- a/pkg/controller/kibana/kibana_controller.go +++ b/pkg/controller/kibana/kibana_controller.go @@ -8,7 +8,7 @@ import ( "reflect" "sync/atomic" - kibanav1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kibanav1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/association" @@ -72,14 +72,14 @@ func add(mgr manager.Manager, r reconcile.Reconciler) (controller.Controller, er func addWatches(c controller.Controller, r *ReconcileKibana) error { // Watch for changes to Kibana - if err := c.Watch(&source.Kind{Type: &kibanav1alpha1.Kibana{}}, &handler.EnqueueRequestForObject{}); err != nil { + if err := c.Watch(&source.Kind{Type: &kibanav1beta1.Kibana{}}, &handler.EnqueueRequestForObject{}); err != nil { return err } // Watch deployments if err := c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &kibanav1alpha1.Kibana{}, + OwnerType: &kibanav1beta1.Kibana{}, }); err != nil { return err } @@ -87,7 +87,7 @@ func addWatches(c controller.Controller, r *ReconcileKibana) error { // Watch services if err := c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &kibanav1alpha1.Kibana{}, + OwnerType: &kibanav1beta1.Kibana{}, }); err != nil { return err } @@ -95,7 +95,7 @@ func addWatches(c controller.Controller, r *ReconcileKibana) error { // Watch secrets if err := c.Watch(&source.Kind{Type: &corev1.Secret{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &kibanav1alpha1.Kibana{}, + OwnerType: &kibanav1beta1.Kibana{}, }); err != nil { return err } @@ -131,7 +131,7 @@ func (r *ReconcileKibana) Reconcile(request reconcile.Request) (reconcile.Result defer common.LogReconciliationRun(log, request, &r.iteration)() // retrieve the kibana object - var kb kibanav1alpha1.Kibana + var kb kibanav1beta1.Kibana if ok, err := association.FetchWithAssociation(r.Client, request, &kb); !ok { return reconcile.Result{}, err } @@ -173,7 +173,7 @@ func (r *ReconcileKibana) Reconcile(request reconcile.Request) (reconcile.Result return r.doReconcile(request, &kb) } -func (r *ReconcileKibana) isCompatible(kb *kibanav1alpha1.Kibana) (bool, error) { +func (r *ReconcileKibana) isCompatible(kb *kibanav1beta1.Kibana) (bool, error) { selector := map[string]string{label.KibanaNameLabelName: kb.Name} compat, err := annotation.ReconcileCompatibility(r.Client, kb, selector, r.params.OperatorInfo.BuildInfo.Version) if err != nil { @@ -183,7 +183,7 @@ func (r *ReconcileKibana) isCompatible(kb *kibanav1alpha1.Kibana) (bool, error) return compat, err } -func (r *ReconcileKibana) doReconcile(request reconcile.Request, kb *kibanav1alpha1.Kibana) (reconcile.Result, error) { +func (r *ReconcileKibana) doReconcile(request reconcile.Request, kb *kibanav1beta1.Kibana) (reconcile.Result, error) { ver, err := version.Parse(kb.Spec.Version) if err != nil { k8s.EmitErrorEvent(r.recorder, err, kb, events.EventReasonValidation, "Invalid version '%s': %v", kb.Spec.Version, err) @@ -223,7 +223,7 @@ func (r *ReconcileKibana) updateStatus(state State) error { } // finalizersFor returns the list of finalizers applying to a given Kibana deployment -func (r *ReconcileKibana) finalizersFor(kb *kibanav1alpha1.Kibana) []finalizer.Finalizer { +func (r *ReconcileKibana) finalizersFor(kb *kibanav1beta1.Kibana) []finalizer.Finalizer { return []finalizer.Finalizer{ secretWatchFinalizer(*kb, r.dynamicWatches), keystore.Finalizer(k8s.ExtractNamespacedName(kb), r.dynamicWatches, kb.Kind()), diff --git a/pkg/controller/kibana/pod/pod.go b/pkg/controller/kibana/pod/pod.go index ad20bc9e82..8f07dc6c81 100644 --- a/pkg/controller/kibana/pod/pod.go +++ b/pkg/controller/kibana/pod/pod.go @@ -7,7 +7,7 @@ package pod import ( "k8s.io/apimachinery/pkg/api/resource" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" "github.com/elastic/cloud-on-k8s/pkg/controller/common/pod" @@ -65,8 +65,8 @@ func imageWithVersion(image string, version string) string { return stringsutil.Concat(image, ":", version) } -func NewPodTemplateSpec(kb v1alpha1.Kibana, keystore *keystore.Resources) corev1.PodTemplateSpec { - builder := defaults.NewPodTemplateBuilder(kb.Spec.PodTemplate, v1alpha1.KibanaContainerName). +func NewPodTemplateSpec(kb v1beta1.Kibana, keystore *keystore.Resources) corev1.PodTemplateSpec { + builder := defaults.NewPodTemplateBuilder(kb.Spec.PodTemplate, v1beta1.KibanaContainerName). WithResources(DefaultResources). WithLabels(label.NewLabels(kb.Name)). WithDockerImage(kb.Spec.Image, imageWithVersion(defaultImageRepositoryAndName, kb.Spec.Version)). @@ -86,5 +86,5 @@ func NewPodTemplateSpec(kb v1alpha1.Kibana, keystore *keystore.Resources) corev1 // GetKibanaContainer returns the Kibana container from the given podSpec. func GetKibanaContainer(podSpec corev1.PodSpec) *corev1.Container { - return pod.ContainerByName(podSpec, v1alpha1.KibanaContainerName) + return pod.ContainerByName(podSpec, v1beta1.KibanaContainerName) } diff --git a/pkg/controller/kibana/pod/pod_test.go b/pkg/controller/kibana/pod/pod_test.go index 2494a24188..9bf06c4597 100644 --- a/pkg/controller/kibana/pod/pod_test.go +++ b/pkg/controller/kibana/pod/pod_test.go @@ -7,7 +7,7 @@ package pod import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/label" "github.com/stretchr/testify/assert" @@ -47,14 +47,14 @@ func Test_imageWithVersion(t *testing.T) { func TestNewPodTemplateSpec(t *testing.T) { tests := []struct { name string - kb v1alpha1.Kibana + kb v1beta1.Kibana keystore *keystore.Resources assertions func(pod corev1.PodTemplateSpec) }{ { name: "defaults", - kb: v1alpha1.Kibana{ - Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{ + Spec: v1beta1.KibanaSpec{ Version: "7.1.0", }, }, @@ -74,8 +74,8 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with additional volumes and init containers for the Keystore", - kb: v1alpha1.Kibana{ - Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{ + Spec: v1beta1.KibanaSpec{ Version: "7.1.0", }, }, @@ -90,7 +90,7 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with custom image", - kb: v1alpha1.Kibana{Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{Spec: v1beta1.KibanaSpec{ Image: "my-custom-image:1.0.0", Version: "7.1.0", }}, @@ -101,7 +101,7 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with default resources", - kb: v1alpha1.Kibana{Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{Spec: v1beta1.KibanaSpec{ Version: "7.1.0", }}, keystore: nil, @@ -111,13 +111,13 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with user-provided resources", - kb: v1alpha1.Kibana{Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{Spec: v1beta1.KibanaSpec{ Version: "7.1.0", PodTemplate: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ { - Name: v1alpha1.KibanaContainerName, + Name: v1beta1.KibanaContainerName, Resources: corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse("3Gi"), @@ -139,7 +139,7 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with user-provided init containers", - kb: v1alpha1.Kibana{Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{Spec: v1beta1.KibanaSpec{ PodTemplate: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ InitContainers: []corev1.Container{ @@ -158,11 +158,11 @@ func TestNewPodTemplateSpec(t *testing.T) { { name: "with user-provided labels", keystore: nil, - kb: v1alpha1.Kibana{ + kb: v1beta1.Kibana{ ObjectMeta: metav1.ObjectMeta{ Name: "kibana-name", }, - Spec: v1alpha1.KibanaSpec{ + Spec: v1beta1.KibanaSpec{ PodTemplate: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ @@ -183,12 +183,12 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with user-provided environment", - kb: v1alpha1.Kibana{Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{Spec: v1beta1.KibanaSpec{ PodTemplate: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ { - Name: v1alpha1.KibanaContainerName, + Name: v1beta1.KibanaContainerName, Env: []corev1.EnvVar{ { Name: "user-env", @@ -206,12 +206,12 @@ func TestNewPodTemplateSpec(t *testing.T) { }, { name: "with user-provided volumes and volume mounts", - kb: v1alpha1.Kibana{Spec: v1alpha1.KibanaSpec{ + kb: v1beta1.Kibana{Spec: v1beta1.KibanaSpec{ PodTemplate: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ { - Name: v1alpha1.KibanaContainerName, + Name: v1beta1.KibanaContainerName, VolumeMounts: []corev1.VolumeMount{ { Name: "user-volume-mount", diff --git a/pkg/controller/kibana/services.go b/pkg/controller/kibana/services.go index 669c7dec7b..44617ed890 100644 --- a/pkg/controller/kibana/services.go +++ b/pkg/controller/kibana/services.go @@ -7,14 +7,14 @@ package kibana import ( corev1 "k8s.io/api/core/v1" - kibanav1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kibanav1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/defaults" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/label" kbname "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/name" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/pod" ) -func NewService(kb kibanav1alpha1.Kibana) *corev1.Service { +func NewService(kb kibanav1beta1.Kibana) *corev1.Service { svc := corev1.Service{ ObjectMeta: kb.Spec.HTTP.Service.ObjectMeta, Spec: kb.Spec.HTTP.Service.Spec, diff --git a/pkg/controller/kibana/state.go b/pkg/controller/kibana/state.go index 7dc911c250..b7475014bf 100644 --- a/pkg/controller/kibana/state.go +++ b/pkg/controller/kibana/state.go @@ -5,7 +5,7 @@ package kibana import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -14,25 +14,25 @@ import ( // State holds the accumulated state during the reconcile loop including the response and a pointer to a Kibana // resource for status updates. type State struct { - Kibana *v1alpha1.Kibana + Kibana *v1beta1.Kibana Request reconcile.Request - originalKibana *v1alpha1.Kibana + originalKibana *v1beta1.Kibana } // NewState creates a new reconcile state based on the given request and Kibana resource with the resource // state reset to empty. -func NewState(request reconcile.Request, kb *v1alpha1.Kibana) State { +func NewState(request reconcile.Request, kb *v1beta1.Kibana) State { return State{Request: request, Kibana: kb, originalKibana: kb.DeepCopy()} } // UpdateKibanaState updates the Kibana status based on the given deployment. func (s State) UpdateKibanaState(deployment v1.Deployment) { s.Kibana.Status.AvailableNodes = int(deployment.Status.AvailableReplicas) // TODO lossy type conversion - s.Kibana.Status.Health = v1alpha1.KibanaRed + s.Kibana.Status.Health = v1beta1.KibanaRed for _, c := range deployment.Status.Conditions { if c.Type == v1.DeploymentAvailable && c.Status == corev1.ConditionTrue { - s.Kibana.Status.Health = v1alpha1.KibanaGreen + s.Kibana.Status.Health = v1beta1.KibanaGreen } } } diff --git a/pkg/controller/kibana/version/version6/settings.go b/pkg/controller/kibana/version/version6/settings.go index 0d9c5d9eff..f10a004019 100644 --- a/pkg/controller/kibana/version/version6/settings.go +++ b/pkg/controller/kibana/version/version6/settings.go @@ -5,7 +5,7 @@ package version6 import ( - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/config" ) diff --git a/pkg/controller/kibana/version/version7/settings.go b/pkg/controller/kibana/version/version7/settings.go index 75a6df5aeb..b73505cd94 100644 --- a/pkg/controller/kibana/version/version7/settings.go +++ b/pkg/controller/kibana/version/version7/settings.go @@ -5,7 +5,7 @@ package version7 import ( - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/config" ) diff --git a/pkg/controller/kibanaassociation/association_controller.go b/pkg/controller/kibanaassociation/association_controller.go index f7d3e8a898..7697a7a1ad 100644 --- a/pkg/controller/kibanaassociation/association_controller.go +++ b/pkg/controller/kibanaassociation/association_controller.go @@ -8,9 +8,9 @@ import ( "reflect" "time" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/association" @@ -186,9 +186,9 @@ func (r *ReconcileAssociation) Reconcile(request reconcile.Request) (reconcile.R return resultFromStatus(newStatus), err } -func resultFromStatus(status commonv1alpha1.AssociationStatus) reconcile.Result { +func resultFromStatus(status commonv1beta1.AssociationStatus) reconcile.Result { switch status { - case commonv1alpha1.AssociationPending: + case commonv1beta1.AssociationPending: return defaultRequeue // retry default: return reconcile.Result{} // we are done or there is not much we can do @@ -205,7 +205,7 @@ func (r *ReconcileAssociation) isCompatible(kibana *kbtype.Kibana) (bool, error) return compat, err } -func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv1alpha1.AssociationStatus, error) { +func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv1beta1.AssociationStatus, error) { kibanaKey := k8s.ExtractNamespacedName(kibana) // garbage collect leftover resources that are not required anymore @@ -217,7 +217,7 @@ func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv // stop watching any ES cluster previously referenced for this Kibana resource r.watches.ElasticsearchClusters.RemoveHandlerForKey(elasticsearchWatchName(kibanaKey)) // other leftover resources are already garbage-collected - return commonv1alpha1.AssociationUnknown, nil + return commonv1beta1.AssociationUnknown, nil } // this Kibana instance references an Elasticsearch cluster @@ -234,7 +234,7 @@ func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv Watched: []types.NamespacedName{esRefKey}, Watcher: kibanaKey, }); err != nil { - return commonv1alpha1.AssociationFailed, err + return commonv1beta1.AssociationFailed, err } userSecretKey := association.UserKey(kibana, kibanaUserSuffix) @@ -244,7 +244,7 @@ func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv Watched: []types.NamespacedName{userSecretKey}, Watcher: kibanaKey, }); err != nil { - return commonv1alpha1.AssociationFailed, err + return commonv1beta1.AssociationFailed, err } var es estype.Elasticsearch @@ -259,12 +259,12 @@ func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv if err := association.RemoveAssociationConf(r.Client, kibana); err != nil && !errors.IsConflict(err) { log.Error(err, "Failed to remove Elasticsearch configuration from Kibana object", "namespace", kibana.Namespace, "kibana_name", kibana.Name) - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } - return commonv1alpha1.AssociationPending, nil + return commonv1beta1.AssociationPending, nil } - return commonv1alpha1.AssociationFailed, err + return commonv1beta1.AssociationFailed, err } if err := association.ReconcileEsUser( @@ -278,17 +278,17 @@ func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv elasticsearchuser.KibanaSystemUserBuiltinRole, kibanaUserSuffix, es); err != nil { - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } caSecret, err := r.reconcileElasticsearchCA(kibana, esRefKey) if err != nil { - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } // construct the expected association configuration authSecret := association.ClearTextSecretKeySelector(kibana, kibanaUserSuffix) - expectedESAssoc := &commonv1alpha1.AssociationConf{ + expectedESAssoc := &commonv1beta1.AssociationConf{ AuthSecretName: authSecret.Name, AuthSecretKey: authSecret.Key, CACertProvided: caSecret.CACertProvided, @@ -301,15 +301,15 @@ func (r *ReconcileAssociation) reconcileInternal(kibana *kbtype.Kibana) (commonv log.Info("Updating Kibana spec with Elasticsearch backend configuration", "namespace", kibana.Namespace, "kibana_name", kibana.Name) if err := association.UpdateAssociationConf(r.Client, kibana, expectedESAssoc); err != nil { if errors.IsConflict(err) { - return commonv1alpha1.AssociationPending, nil + return commonv1beta1.AssociationPending, nil } log.Error(err, "Failed to update association configuration", "namespace", kibana.Namespace, "kibana_name", kibana.Name) - return commonv1alpha1.AssociationPending, err + return commonv1beta1.AssociationPending, err } kibana.SetAssociationConf(expectedESAssoc) } - return commonv1alpha1.AssociationEstablished, nil + return commonv1beta1.AssociationEstablished, nil } func (r *ReconcileAssociation) reconcileElasticsearchCA(kibana *kbtype.Kibana, es types.NamespacedName) (association.CASecret, error) { diff --git a/pkg/controller/kibanaassociation/association_controller_test.go b/pkg/controller/kibanaassociation/association_controller_test.go index d62aa2677b..d86ab914f3 100644 --- a/pkg/controller/kibanaassociation/association_controller_test.go +++ b/pkg/controller/kibanaassociation/association_controller_test.go @@ -7,10 +7,10 @@ package kibanaassociation import ( "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/association" "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" @@ -38,7 +38,7 @@ var esFixture = estype.Elasticsearch{ } var esRefFixture = metav1.OwnerReference{ - APIVersion: "elasticsearch.k8s.elastic.co/v1alpha1", + APIVersion: "elasticsearch.k8s.elastic.co/v1beta1", Kind: "Elasticsearch", Name: "es-foo", UID: "f8d564d9-885e-11e9-896d-08002703f062", @@ -68,7 +68,7 @@ var kibanaFixtureObjectMeta = metav1.ObjectMeta{ var kibanaFixture = kbtype.Kibana{ ObjectMeta: kibanaFixtureObjectMeta, Spec: kbtype.KibanaSpec{ - ElasticsearchRef: commonv1alpha1.ObjectSelector{ + ElasticsearchRef: commonv1beta1.ObjectSelector{ Name: esFixture.Name, Namespace: esFixture.Namespace, }, @@ -77,7 +77,7 @@ var kibanaFixture = kbtype.Kibana{ var t = true var ownerRefFixture = metav1.OwnerReference{ - APIVersion: "kibana.k8s.elastic.co/v1alpha1", + APIVersion: "kibana.k8s.elastic.co/v1beta1", Kind: "Kibana", Name: "foo", UID: kibanaFixtureUID, @@ -90,7 +90,7 @@ func Test_deleteOrphanedResources(t *testing.T) { tests := []struct { name string kibana kbtype.Kibana - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch initialObjects []runtime.Object postCondition func(c k8s.Client) wantErr bool @@ -100,7 +100,7 @@ func Test_deleteOrphanedResources(t *testing.T) { kibana: kbtype.Kibana{ ObjectMeta: kibanaFixtureObjectMeta, Spec: kbtype.KibanaSpec{ - ElasticsearchRef: commonv1alpha1.ObjectSelector{ // ElasticsearchRef without a namespace + ElasticsearchRef: commonv1beta1.ObjectSelector{ // ElasticsearchRef without a namespace Name: esFixture.Name, //Namespace: esFixture.Namespace, No namespace on purpose }, @@ -149,7 +149,7 @@ func Test_deleteOrphanedResources(t *testing.T) { kibana: kbtype.Kibana{ ObjectMeta: kibanaFixtureObjectMeta, Spec: kbtype.KibanaSpec{ - ElasticsearchRef: commonv1alpha1.ObjectSelector{ + ElasticsearchRef: commonv1beta1.ObjectSelector{ Name: esFixture.Name, Namespace: "ns2", // Kibana does not reference the default namespace anymore }, diff --git a/pkg/controller/kibanaassociation/labels.go b/pkg/controller/kibanaassociation/labels.go index bc4b5433ae..5df510956a 100644 --- a/pkg/controller/kibanaassociation/labels.go +++ b/pkg/controller/kibanaassociation/labels.go @@ -5,7 +5,7 @@ package kibanaassociation import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,7 +27,7 @@ func NewResourceSelector(name string) client.MatchingLabels { }) } -func hasBeenCreatedBy(object metav1.Object, kibana *v1alpha1.Kibana) bool { +func hasBeenCreatedBy(object metav1.Object, kibana *v1beta1.Kibana) bool { labels := object.GetLabels() if name, ok := labels[AssociationLabelName]; !ok || name != kibana.Name { return false diff --git a/pkg/controller/kibanaassociation/watch.go b/pkg/controller/kibanaassociation/watch.go index e5e0adacb9..0e5a98fbbd 100644 --- a/pkg/controller/kibanaassociation/watch.go +++ b/pkg/controller/kibanaassociation/watch.go @@ -5,8 +5,8 @@ package kibanaassociation import ( - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/finalizer" "github.com/elastic/cloud-on-k8s/pkg/controller/common/watches" corev1 "k8s.io/api/core/v1" diff --git a/pkg/controller/license/license_controller.go b/pkg/controller/license/license_controller.go index 8773fb56ee..3d97bb4507 100644 --- a/pkg/controller/license/license_controller.go +++ b/pkg/controller/license/license_controller.go @@ -10,7 +10,7 @@ import ( "reflect" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" @@ -98,7 +98,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { // Watch for changes to Elasticsearch clusters. if err := c.Watch( - &source.Kind{Type: &v1alpha1.Elasticsearch{}}, &handler.EnqueueRequestForObject{}, + &source.Kind{Type: &v1beta1.Elasticsearch{}}, &handler.EnqueueRequestForObject{}, ); err != nil { return err } @@ -161,7 +161,7 @@ func findLicense(c k8s.Client, checker license.Checker) (esclient.License, strin // reconcileSecret upserts a secret in the namespace of the Elasticsearch cluster containing the signature of its license. func reconcileSecret( c k8s.Client, - cluster v1alpha1.Elasticsearch, + cluster v1beta1.Elasticsearch, parent string, esLicense esclient.License, ) error { @@ -204,7 +204,7 @@ func reconcileSecret( } // reconcileClusterLicense upserts a cluster license in the namespace of the given Elasticsearch cluster. -func (r *ReconcileLicenses) reconcileClusterLicense(cluster v1alpha1.Elasticsearch) (time.Time, error) { +func (r *ReconcileLicenses) reconcileClusterLicense(cluster v1beta1.Elasticsearch) (time.Time, error) { var noResult time.Time matchingSpec, parent, found, err := findLicense(r, r.checker) if err != nil { @@ -223,7 +223,7 @@ func (r *ReconcileLicenses) reconcileClusterLicense(cluster v1alpha1.Elasticsear func (r *ReconcileLicenses) reconcileInternal(request reconcile.Request) (reconcile.Result, error) { // Fetch the cluster to ensure it still exists - cluster := v1alpha1.Elasticsearch{} + cluster := v1beta1.Elasticsearch{} err := r.Get(request.NamespacedName, &cluster) if err != nil { if errors.IsNotFound(err) { diff --git a/pkg/controller/license/license_controller_integration_test.go b/pkg/controller/license/license_controller_integration_test.go index 8ceef6993e..206b3c51e7 100644 --- a/pkg/controller/license/license_controller_integration_test.go +++ b/pkg/controller/license/license_controller_integration_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" @@ -89,15 +89,15 @@ func TestReconcile(t *testing.T) { }) varFalse := false - cluster := &v1alpha1.Elasticsearch{ + cluster := &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: "default", }, - Spec: v1alpha1.ElasticsearchSpec{ + Spec: v1beta1.ElasticsearchSpec{ Version: "7.0.0", SetVMMaxMapCount: &varFalse, - Nodes: []v1alpha1.NodeSpec{ + Nodes: []v1beta1.NodeSpec{ { Name: "all", NodeCount: 3, diff --git a/pkg/controller/license/license_controller_test.go b/pkg/controller/license/license_controller_test.go index eb1b3bdf71..4c8a94368f 100644 --- a/pkg/controller/license/license_controller_test.go +++ b/pkg/controller/license/license_controller_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" commonlicense "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" esname "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" @@ -73,7 +73,7 @@ func Test_nextReconcileRelativeTo(t *testing.T) { } } -var cluster = &v1alpha1.Elasticsearch{ +var cluster = &v1beta1.Elasticsearch{ ObjectMeta: metav1.ObjectMeta{ Name: "cluster", Namespace: "namespace", @@ -117,7 +117,7 @@ func enterpriseLicense(t *testing.T, licenseType commonlicense.ElasticsearchLice func TestReconcileLicenses_reconcileInternal(t *testing.T) { tests := []struct { name string - cluster *v1alpha1.Elasticsearch + cluster *v1beta1.Elasticsearch k8sResources []runtime.Object wantErr string wantNewLicense bool @@ -172,7 +172,7 @@ func TestReconcileLicenses_reconcileInternal(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.NoError(t, v1alpha1.AddToScheme(scheme.Scheme)) + require.NoError(t, v1beta1.AddToScheme(scheme.Scheme)) client := k8s.WrapClient(fake.NewFakeClient(tt.k8sResources...)) r := &ReconcileLicenses{ Client: client, diff --git a/pkg/controller/license/list_test.go b/pkg/controller/license/list_test.go index e11bcdf4ff..6d1ab6a4d2 100644 --- a/pkg/controller/license/list_test.go +++ b/pkg/controller/license/list_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/pkg/errors" @@ -36,7 +36,7 @@ var _ k8s.Client = &failingClient{} func Test_listAffectedLicenses(t *testing.T) { s := scheme.Scheme - if err := v1alpha1.SchemeBuilder.AddToScheme(s); err != nil { + if err := v1beta1.SchemeBuilder.AddToScheme(s); err != nil { assert.Fail(t, "failed to build custom scheme") } diff --git a/test/e2e/apm/association_test.go b/test/e2e/apm/association_test.go index 597278014e..8493caa1a4 100644 --- a/test/e2e/apm/association_test.go +++ b/test/e2e/apm/association_test.go @@ -8,8 +8,8 @@ import ( "fmt" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -53,7 +53,7 @@ func TestCrossNSAssociation(t *testing.T) { func TestAPMAssociationWithNonExistentES(t *testing.T) { name := "test-apm-assoc-non-existent-es" apmBuilder := apmserver.NewBuilder(name). - WithElasticsearchRef(commonv1alpha1.ObjectSelector{ + WithElasticsearchRef(commonv1beta1.ObjectSelector{ Name: "non-existent-es", }). WithNodeCount(1) @@ -97,7 +97,7 @@ func TestAPMAssociationWhenReferencedESDisappears(t *testing.T) { test.Step{ Name: "Updating to invalid Elasticsearch reference should succeed", Test: func(t *testing.T) { - var apm v1alpha1.ApmServer + var apm v1beta1.ApmServer require.NoError(t, k.Client.Get(k8s.ExtractNamespacedName(&apmBuilder.ApmServer), &apm)) apm.Spec.ElasticsearchRef.Namespace = "xxxx" require.NoError(t, k.Client.Update(&apm)) @@ -119,11 +119,11 @@ func TestAPMAssociationWhenReferencedESDisappears(t *testing.T) { switch { case evt.Type == corev1.EventTypeNormal && evt.Reason == events.EventAssociationStatusChange: prevStatus, currStatus := annotation.ExtractAssociationStatus(evt.ObjectMeta) - if prevStatus == commonv1alpha1.AssociationEstablished && currStatus != prevStatus { + if prevStatus == commonv1beta1.AssociationEstablished && currStatus != prevStatus { assocLostEventSeen = true } - if currStatus == commonv1alpha1.AssociationEstablished { + if currStatus == commonv1beta1.AssociationEstablished { assocEstablishedEventSeen = true } case evt.Type == corev1.EventTypeWarning && evt.Reason == events.EventAssociationError: diff --git a/test/e2e/apm/configuration_test.go b/test/e2e/apm/configuration_test.go index 0fc4716b22..e8dcfd51b8 100644 --- a/test/e2e/apm/configuration_test.go +++ b/test/e2e/apm/configuration_test.go @@ -8,8 +8,8 @@ import ( "fmt" "testing" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/services" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" @@ -112,7 +112,7 @@ func TestUpdateConfiguration(t *testing.T) { var apm apmtype.ApmServer require.NoError(t, k.Client.Get(apmNamespacedName, &apm)) - apm.Spec.SecureSettings = []commonv1alpha1.SecretSource{ + apm.Spec.SecureSettings = []commonv1beta1.SecretSource{ {SecretName: secureSettingsSecretName}, } require.NoError(t, k.Client.Update(&apm)) @@ -149,7 +149,7 @@ func TestUpdateConfiguration(t *testing.T) { var apm apmtype.ApmServer require.NoError(t, k.Client.Get(apmNamespacedName, &apm)) - customConfig := commonv1alpha1.Config{ + customConfig := commonv1beta1.Config{ Data: map[string]interface{}{"output.elasticsearch.compression_level": 1}, } apm.Spec.Config = &customConfig diff --git a/test/e2e/apm/standalone_test.go b/test/e2e/apm/standalone_test.go index 353206a59f..b5ca5b4021 100644 --- a/test/e2e/apm/standalone_test.go +++ b/test/e2e/apm/standalone_test.go @@ -7,7 +7,7 @@ package apm import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/elastic/cloud-on-k8s/test/e2e/test/apmserver" ) @@ -32,9 +32,9 @@ func TestApmStandaloneNoTLS(t *testing.T) { "pretty": true, }, }). - WithHTTPCfg(v1alpha1.HTTPConfig{ - TLS: v1alpha1.TLSOptions{ - SelfSignedCertificate: &v1alpha1.SelfSignedCertificate{ + WithHTTPCfg(v1beta1.HTTPConfig{ + TLS: v1beta1.TLSOptions{ + SelfSignedCertificate: &v1beta1.SelfSignedCertificate{ Disabled: true, }, }, diff --git a/test/e2e/es/certs_test.go b/test/e2e/es/certs_test.go index 75572fe922..9a540347f2 100644 --- a/test/e2e/es/certs_test.go +++ b/test/e2e/es/certs_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" esname "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" "github.com/elastic/cloud-on-k8s/pkg/dev/portforward" @@ -61,7 +61,7 @@ func TestUpdateHTTPCertSAN(t *testing.T) { { Name: "Add load balancer IP to the SAN", Test: func(t *testing.T) { - var currentEs v1alpha1.Elasticsearch + var currentEs v1beta1.Elasticsearch err := k.Client.Get(k8s.ExtractNamespacedName(&b.Elasticsearch), ¤tEs) require.NoError(t, err) diff --git a/test/e2e/es/keystore_test.go b/test/e2e/es/keystore_test.go index 9c53c3766e..a142a806b5 100644 --- a/test/e2e/es/keystore_test.go +++ b/test/e2e/es/keystore_test.go @@ -7,7 +7,7 @@ package es import ( "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/elastic/cloud-on-k8s/test/e2e/test/elasticsearch" diff --git a/test/e2e/es/naming_test.go b/test/e2e/es/naming_test.go index 9bae7626d1..4ad957220d 100644 --- a/test/e2e/es/naming_test.go +++ b/test/e2e/es/naming_test.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/validation" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/name" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) diff --git a/test/e2e/es/podtemplate_test.go b/test/e2e/es/podtemplate_test.go index 59ec566a80..69729ef477 100644 --- a/test/e2e/es/podtemplate_test.go +++ b/test/e2e/es/podtemplate_test.go @@ -11,7 +11,7 @@ import ( "net/http" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/elastic/cloud-on-k8s/test/e2e/test/elasticsearch" @@ -50,7 +50,7 @@ func TestCustomConfiguration(t *testing.T) { }, Containers: []corev1.Container{ { - Name: v1alpha1.ElasticsearchContainerName, + Name: v1beta1.ElasticsearchContainerName, Resources: elasticsearch.DefaultResources, VolumeMounts: []corev1.VolumeMount{ { diff --git a/test/e2e/es/reversal_test.go b/test/e2e/es/reversal_test.go index 4861ee20ab..937cd8a2c8 100644 --- a/test/e2e/es/reversal_test.go +++ b/test/e2e/es/reversal_test.go @@ -7,8 +7,8 @@ package es import ( "testing" - common "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + common "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/elastic/cloud-on-k8s/test/e2e/test/elasticsearch" ) @@ -57,13 +57,13 @@ func TestReversalStatefulSetRename(t *testing.T) { func TestRiskyMasterReconfiguration(t *testing.T) { b := elasticsearch.NewBuilder("test-sset-reconfig-reversal"). WithESMasterDataNodes(1, elasticsearch.DefaultResources). - WithNodeSpec(v1alpha1.NodeSpec{ + WithNodeSpec(v1beta1.NodeSpec{ Name: "other-master", NodeCount: 1, Config: &common.Config{ Data: map[string]interface{}{ - v1alpha1.NodeMaster: true, - v1alpha1.NodeData: true, + v1beta1.NodeMaster: true, + v1beta1.NodeData: true, }, }, PodTemplate: elasticsearch.ESPodTemplate(elasticsearch.DefaultResources), @@ -71,13 +71,13 @@ func TestRiskyMasterReconfiguration(t *testing.T) { // this currently breaks the cluster (something we might fix in the future at which point this just tests a temp downscale) noMasterMaster := b.WithNoESTopology().WithESMasterDataNodes(1, elasticsearch.DefaultResources). - WithNodeSpec(v1alpha1.NodeSpec{ + WithNodeSpec(v1beta1.NodeSpec{ Name: "other-master", NodeCount: 1, Config: &common.Config{ Data: map[string]interface{}{ - v1alpha1.NodeMaster: false, - v1alpha1.NodeData: true, + v1beta1.NodeMaster: false, + v1beta1.NodeData: true, }, }, PodTemplate: elasticsearch.ESPodTemplate(elasticsearch.DefaultResources), diff --git a/test/e2e/kb/association_test.go b/test/e2e/kb/association_test.go index 1c081aaf49..8d1c89b19c 100644 --- a/test/e2e/kb/association_test.go +++ b/test/e2e/kb/association_test.go @@ -8,8 +8,8 @@ import ( "fmt" "testing" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/annotation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/events" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -90,7 +90,7 @@ func TestKibanaAssociationWhenReferencedESDisappears(t *testing.T) { test.Step{ Name: "Updating to invalid Elasticsearch reference should succeed", Test: func(t *testing.T) { - var kb v1alpha1.Kibana + var kb v1beta1.Kibana require.NoError(t, k.Client.Get(k8s.ExtractNamespacedName(&kbBuilder.Kibana), &kb)) kb.Spec.ElasticsearchRef.Namespace = "xxxx" require.NoError(t, k.Client.Update(&kb)) @@ -112,11 +112,11 @@ func TestKibanaAssociationWhenReferencedESDisappears(t *testing.T) { switch { case evt.Type == corev1.EventTypeNormal && evt.Reason == events.EventAssociationStatusChange: prevStatus, currStatus := annotation.ExtractAssociationStatus(evt.ObjectMeta) - if prevStatus == commonv1alpha1.AssociationEstablished && currStatus != prevStatus { + if prevStatus == commonv1beta1.AssociationEstablished && currStatus != prevStatus { assocLostEventSeen = true } - if currStatus == commonv1alpha1.AssociationEstablished { + if currStatus == commonv1beta1.AssociationEstablished { assocEstablishedEventSeen = true } case evt.Type == corev1.EventTypeWarning && evt.Reason == events.EventAssociationError: diff --git a/test/e2e/kb/keystore_test.go b/test/e2e/kb/keystore_test.go index fc4f48e374..5ac9baf525 100644 --- a/test/e2e/kb/keystore_test.go +++ b/test/e2e/kb/keystore_test.go @@ -7,7 +7,7 @@ package kb import ( "testing" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/elastic/cloud-on-k8s/test/e2e/test/elasticsearch" diff --git a/test/e2e/test/apmserver/builder.go b/test/e2e/test/apmserver/builder.go index f8162631de..1de019603a 100644 --- a/test/e2e/test/apmserver/builder.go +++ b/test/e2e/test/apmserver/builder.go @@ -5,8 +5,8 @@ package apmserver import ( - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" "github.com/elastic/cloud-on-k8s/test/e2e/test" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -40,7 +40,7 @@ func newBuilder(name, randSuffix string) Builder { Spec: apmtype.ApmServerSpec{ NodeCount: 1, Version: test.Ctx().ElasticStackVersion, - Config: &commonv1alpha1.Config{ + Config: &commonv1beta1.Config{ Data: map[string]interface{}{ "apm-server.ilm.enabled": false, }, @@ -82,19 +82,19 @@ func (b Builder) WithNodeCount(count int) Builder { return b } -func (b Builder) WithElasticsearchRef(ref commonv1alpha1.ObjectSelector) Builder { +func (b Builder) WithElasticsearchRef(ref commonv1beta1.ObjectSelector) Builder { b.ApmServer.Spec.ElasticsearchRef = ref return b } func (b Builder) WithConfig(cfg map[string]interface{}) Builder { - b.ApmServer.Spec.Config = &commonv1alpha1.Config{ + b.ApmServer.Spec.Config = &commonv1beta1.Config{ Data: cfg, } return b } -func (b Builder) WithHTTPCfg(cfg commonv1alpha1.HTTPConfig) Builder { +func (b Builder) WithHTTPCfg(cfg commonv1beta1.HTTPConfig) Builder { b.ApmServer.Spec.HTTP = cfg return b } diff --git a/test/e2e/test/apmserver/checks_apm.go b/test/e2e/test/apmserver/checks_apm.go index b1b9299fa7..3c6f51dc2c 100644 --- a/test/e2e/test/apmserver/checks_apm.go +++ b/test/e2e/test/apmserver/checks_apm.go @@ -13,8 +13,8 @@ import ( "strings" "testing" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" @@ -65,7 +65,7 @@ func (c *apmClusterChecks) BuildApmServerClient(apm apmtype.ApmServer, k *test.K } // We assume here that the Elasticsearch object has been created before the APM Server. - var es v1alpha1.Elasticsearch + var es v1beta1.Elasticsearch namespace := apm.Spec.ElasticsearchRef.Namespace if len(namespace) == 0 { namespace = apm.Namespace diff --git a/test/e2e/test/apmserver/http_client.go b/test/e2e/test/apmserver/http_client.go index e8458e81fd..c4e7fd8a5b 100644 --- a/test/e2e/test/apmserver/http_client.go +++ b/test/e2e/test/apmserver/http_client.go @@ -15,7 +15,7 @@ import ( "strings" "time" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/config" "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/name" diff --git a/test/e2e/test/apmserver/steps_creation.go b/test/e2e/test/apmserver/steps_creation.go index 972cd98bd7..f18db1ab0d 100644 --- a/test/e2e/test/apmserver/steps_creation.go +++ b/test/e2e/test/apmserver/steps_creation.go @@ -7,7 +7,7 @@ package apmserver import ( "testing" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" diff --git a/test/e2e/test/apmserver/steps_init.go b/test/e2e/test/apmserver/steps_init.go index ae22fbf60b..ee792a706c 100644 --- a/test/e2e/test/apmserver/steps_init.go +++ b/test/e2e/test/apmserver/steps_init.go @@ -7,7 +7,7 @@ package apmserver import ( "testing" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" diff --git a/test/e2e/test/elasticsearch/builder.go b/test/e2e/test/elasticsearch/builder.go index c92cbbf2d2..f127abca33 100644 --- a/test/e2e/test/elasticsearch/builder.go +++ b/test/e2e/test/elasticsearch/builder.go @@ -5,9 +5,9 @@ package elasticsearch import ( - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/volume" "github.com/elastic/cloud-on-k8s/test/e2e/test" corev1 "k8s.io/api/core/v1" @@ -23,7 +23,7 @@ func ESPodTemplate(resources corev1.ResourceRequirements) corev1.PodTemplateSpec SecurityContext: test.DefaultSecurityContext(), Containers: []corev1.Container{ { - Name: v1alpha1.ElasticsearchContainerName, + Name: v1beta1.ElasticsearchContainerName, Resources: resources, }, }, @@ -70,8 +70,8 @@ func (b Builder) WithSuffix(suffix string) Builder { return b } -func (b Builder) Ref() commonv1alpha1.ObjectSelector { - return commonv1alpha1.ObjectSelector{ +func (b Builder) Ref() commonv1beta1.ObjectSelector { + return commonv1beta1.ObjectSelector{ Name: b.Elasticsearch.Name, Namespace: b.Elasticsearch.Namespace, } @@ -104,7 +104,7 @@ func (b Builder) WithHTTPLoadBalancer() Builder { func (b Builder) WithTLSDisabled(disabled bool) Builder { if b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate == nil { - b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate = &commonv1alpha1.SelfSignedCertificate{} + b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate = &commonv1beta1.SelfSignedCertificate{} } else { b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate = b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate.DeepCopy() } @@ -113,8 +113,8 @@ func (b Builder) WithTLSDisabled(disabled bool) Builder { } func (b Builder) WithHTTPSAN(ip string) Builder { - b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate = &commonv1alpha1.SelfSignedCertificate{ - SubjectAlternativeNames: []commonv1alpha1.SubjectAlternativeName{{IP: ip}}, + b.Elasticsearch.Spec.HTTP.TLS.SelfSignedCertificate = &commonv1beta1.SelfSignedCertificate{ + SubjectAlternativeNames: []commonv1beta1.SubjectAlternativeName{{IP: ip}}, } return b } @@ -130,7 +130,7 @@ func (b Builder) WithESMasterNodes(count int, resources corev1.ResourceRequireme return b.WithNodeSpec(estype.NodeSpec{ Name: "master", NodeCount: int32(count), - Config: &commonv1alpha1.Config{ + Config: &commonv1beta1.Config{ Data: map[string]interface{}{ estype.NodeData: "false", }, @@ -143,7 +143,7 @@ func (b Builder) WithESDataNodes(count int, resources corev1.ResourceRequirement return b.WithNodeSpec(estype.NodeSpec{ Name: "data", NodeCount: int32(count), - Config: &commonv1alpha1.Config{ + Config: &commonv1beta1.Config{ Data: map[string]interface{}{ estype.NodeMaster: "false", }, @@ -156,7 +156,7 @@ func (b Builder) WithESMasterDataNodes(count int, resources corev1.ResourceRequi return b.WithNodeSpec(estype.NodeSpec{ Name: "masterdata", NodeCount: int32(count), - Config: &commonv1alpha1.Config{ + Config: &commonv1beta1.Config{ Data: map[string]interface{}{}, }, PodTemplate: ESPodTemplate(resources), @@ -169,9 +169,9 @@ func (b Builder) WithNodeSpec(nodeSpec estype.NodeSpec) Builder { } func (b Builder) WithESSecureSettings(secretNames ...string) Builder { - refs := make([]commonv1alpha1.SecretSource, 0, len(secretNames)) + refs := make([]commonv1beta1.SecretSource, 0, len(secretNames)) for i := range secretNames { - refs = append(refs, commonv1alpha1.SecretSource{SecretName: secretNames[i]}) + refs = append(refs, commonv1beta1.SecretSource{SecretName: secretNames[i]}) } b.Elasticsearch.Spec.SecureSettings = refs return b diff --git a/test/e2e/test/elasticsearch/checks_es.go b/test/e2e/test/elasticsearch/checks_es.go index 8091045e2f..a8a1cff708 100644 --- a/test/e2e/test/elasticsearch/checks_es.go +++ b/test/e2e/test/elasticsearch/checks_es.go @@ -9,8 +9,8 @@ import ( "fmt" "strconv" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/test/e2e/test" "k8s.io/apimachinery/pkg/api/resource" @@ -155,7 +155,7 @@ func (e *esClusterChecks) CheckESNodesTopology(es estype.Elasticsearch) test.Ste nodeStats := nodesStats.Nodes[nodeID] for i, topoElem := range expectedTopology { - cfg, err := v1alpha1.UnpackConfig(topoElem.Config) + cfg, err := v1beta1.UnpackConfig(topoElem.Config) if err != nil { return err } @@ -205,7 +205,7 @@ func rolesToConfig(roles []string) estype.Node { func compareMemoryLimit(topologyElement estype.NodeSpec, cgroupMemoryLimitsInBytes int64) bool { var memoryLimit *resource.Quantity for _, c := range topologyElement.PodTemplate.Spec.Containers { - if c.Name == v1alpha1.ElasticsearchContainerName { + if c.Name == v1beta1.ElasticsearchContainerName { memoryLimit = c.Resources.Limits.Memory() } } diff --git a/test/e2e/test/elasticsearch/checks_k8s.go b/test/e2e/test/elasticsearch/checks_k8s.go index 0a958c3a16..21a9fdc9bd 100644 --- a/test/e2e/test/elasticsearch/checks_k8s.go +++ b/test/e2e/test/elasticsearch/checks_k8s.go @@ -7,7 +7,7 @@ package elasticsearch import ( "fmt" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" esname "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" diff --git a/test/e2e/test/elasticsearch/checks_limiting.go b/test/e2e/test/elasticsearch/checks_limiting.go index 9373d13834..e5ef51df85 100644 --- a/test/e2e/test/elasticsearch/checks_limiting.go +++ b/test/e2e/test/elasticsearch/checks_limiting.go @@ -9,7 +9,7 @@ import ( "math" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) @@ -18,12 +18,12 @@ type MasterChangeBudgetCheck struct { Observations []int Errors []error stopChan chan struct{} - es v1alpha1.Elasticsearch + es v1beta1.Elasticsearch interval time.Duration client k8s.Client } -func NewMasterChangeBudgetCheck(es v1alpha1.Elasticsearch, interval time.Duration, client k8s.Client) *MasterChangeBudgetCheck { +func NewMasterChangeBudgetCheck(es v1beta1.Elasticsearch, interval time.Duration, client k8s.Client) *MasterChangeBudgetCheck { return &MasterChangeBudgetCheck{ es: es, interval: interval, diff --git a/test/e2e/test/elasticsearch/checks_volume.go b/test/e2e/test/elasticsearch/checks_volume.go index 1134d69105..5a15081da5 100644 --- a/test/e2e/test/elasticsearch/checks_volume.go +++ b/test/e2e/test/elasticsearch/checks_volume.go @@ -7,7 +7,7 @@ package elasticsearch import ( "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/volume" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" diff --git a/test/e2e/test/elasticsearch/cluster_uuid.go b/test/e2e/test/elasticsearch/cluster_uuid.go index 951c9dbbda..9f08b6f0e3 100644 --- a/test/e2e/test/elasticsearch/cluster_uuid.go +++ b/test/e2e/test/elasticsearch/cluster_uuid.go @@ -9,13 +9,13 @@ import ( "fmt" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" ) -func clusterUUID(es v1alpha1.Elasticsearch, k *test.K8sClient) (string, error) { +func clusterUUID(es v1beta1.Elasticsearch, k *test.K8sClient) (string, error) { client, err := NewElasticsearchClient(es, k) if err != nil { return "", err @@ -30,7 +30,7 @@ func clusterUUID(es v1alpha1.Elasticsearch, k *test.K8sClient) (string, error) { } // RetrieveClusterUUIDStep stores the current clusterUUID into the given futureClusterUUID -func RetrieveClusterUUIDStep(es v1alpha1.Elasticsearch, k *test.K8sClient, futureClusterUUID *string) test.Step { +func RetrieveClusterUUIDStep(es v1beta1.Elasticsearch, k *test.K8sClient, futureClusterUUID *string) test.Step { return test.Step{ Name: "Retrieve Elasticsearch cluster UUID for comparison purpose", Test: test.Eventually(func() error { @@ -50,7 +50,7 @@ func RetrieveClusterUUIDStep(es v1alpha1.Elasticsearch, k *test.K8sClient, futur // CompareClusterUUIDStep compares the current clusterUUID with previousClusterUUID, // and fails if they don't match -func CompareClusterUUIDStep(es v1alpha1.Elasticsearch, k *test.K8sClient, previousClusterUUID *string) test.Step { +func CompareClusterUUIDStep(es v1beta1.Elasticsearch, k *test.K8sClient, previousClusterUUID *string) test.Step { return test.Step{ Name: "Cluster UUID should have been preserved", Test: func(t *testing.T) { diff --git a/test/e2e/test/elasticsearch/http_client.go b/test/e2e/test/elasticsearch/http_client.go index 0215d318ee..6e14144e11 100644 --- a/test/e2e/test/elasticsearch/http_client.go +++ b/test/e2e/test/elasticsearch/http_client.go @@ -5,7 +5,7 @@ package elasticsearch import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/name" @@ -18,7 +18,7 @@ import ( ) // NewElasticsearchClient returns an ES client for the given ES cluster -func NewElasticsearchClient(es v1alpha1.Elasticsearch, k *test.K8sClient) (client.Client, error) { +func NewElasticsearchClient(es v1beta1.Elasticsearch, k *test.K8sClient) (client.Client, error) { password, err := k.GetElasticPassword(es.Namespace, es.Name) if err != nil { return nil, err diff --git a/test/e2e/test/elasticsearch/pause.go b/test/e2e/test/elasticsearch/pause.go index 8f7a22de69..300f2dd858 100644 --- a/test/e2e/test/elasticsearch/pause.go +++ b/test/e2e/test/elasticsearch/pause.go @@ -8,17 +8,17 @@ import ( "fmt" "strconv" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" ) -func togglePauseOn(paused bool, es v1alpha1.Elasticsearch, k *test.K8sClient) test.Step { +func togglePauseOn(paused bool, es v1beta1.Elasticsearch, k *test.K8sClient) test.Step { return test.Step{ Name: fmt.Sprintf("Should pause reconciliation %v", paused), Test: test.Eventually(func() error { - var curr v1alpha1.Elasticsearch + var curr v1beta1.Elasticsearch if err := k.Client.Get(k8s.ExtractNamespacedName(&es), &curr); err != nil { return err } @@ -33,10 +33,10 @@ func togglePauseOn(paused bool, es v1alpha1.Elasticsearch, k *test.K8sClient) te } } -func PauseReconciliation(es v1alpha1.Elasticsearch, k *test.K8sClient) test.Step { +func PauseReconciliation(es v1beta1.Elasticsearch, k *test.K8sClient) test.Step { return togglePauseOn(true, es, k) } -func ResumeReconciliation(es v1alpha1.Elasticsearch, k *test.K8sClient) test.Step { +func ResumeReconciliation(es v1beta1.Elasticsearch, k *test.K8sClient) test.Step { return togglePauseOn(false, es, k) } diff --git a/test/e2e/test/elasticsearch/settings.go b/test/e2e/test/elasticsearch/settings.go index 67c843e325..70490cec99 100644 --- a/test/e2e/test/elasticsearch/settings.go +++ b/test/e2e/test/elasticsearch/settings.go @@ -5,12 +5,12 @@ package elasticsearch import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/settings" ) -func MustNumDataNodes(es v1alpha1.Elasticsearch) int { +func MustNumDataNodes(es v1beta1.Elasticsearch) int { var numNodes int for _, n := range es.Spec.Nodes { if isDataNode(n) { @@ -20,9 +20,9 @@ func MustNumDataNodes(es v1alpha1.Elasticsearch) int { return numNodes } -func isDataNode(node v1alpha1.NodeSpec) bool { +func isDataNode(node v1beta1.NodeSpec) bool { if node.Config == nil { - return v1alpha1.DefaultCfg.Node.Data // if not specified use the default + return v1beta1.DefaultCfg.Node.Data // if not specified use the default } config, err := common.NewCanonicalConfigFrom(node.Config.Data) if err != nil { diff --git a/test/e2e/test/elasticsearch/steps_creation.go b/test/e2e/test/elasticsearch/steps_creation.go index cd6ff0db60..aa5ca3aba4 100644 --- a/test/e2e/test/elasticsearch/steps_creation.go +++ b/test/e2e/test/elasticsearch/steps_creation.go @@ -7,7 +7,7 @@ package elasticsearch import ( "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" diff --git a/test/e2e/test/elasticsearch/steps_init.go b/test/e2e/test/elasticsearch/steps_init.go index 384d9ed101..4dd886b6cb 100644 --- a/test/e2e/test/elasticsearch/steps_init.go +++ b/test/e2e/test/elasticsearch/steps_init.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" diff --git a/test/e2e/test/elasticsearch/steps_license.go b/test/e2e/test/elasticsearch/steps_license.go index 301a4d1bd8..9904373275 100644 --- a/test/e2e/test/elasticsearch/steps_license.go +++ b/test/e2e/test/elasticsearch/steps_license.go @@ -9,7 +9,7 @@ import ( "fmt" "testing" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/utils/stringsutil" diff --git a/test/e2e/test/elasticsearch/steps_mutation.go b/test/e2e/test/elasticsearch/steps_mutation.go index c749cb02b6..dabfc36a98 100644 --- a/test/e2e/test/elasticsearch/steps_mutation.go +++ b/test/e2e/test/elasticsearch/steps_mutation.go @@ -10,7 +10,7 @@ import ( "testing" "time" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" esclient "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" diff --git a/test/e2e/test/k8s_client.go b/test/e2e/test/k8s_client.go index eabc6bb3e2..049e1bea1a 100644 --- a/test/e2e/test/k8s_client.go +++ b/test/e2e/test/k8s_client.go @@ -10,9 +10,9 @@ import ( "fmt" "os" - apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1" + estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" apmlabels "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" diff --git a/test/e2e/test/kibana/builder.go b/test/e2e/test/kibana/builder.go index 7b34202bdc..8d067f2dab 100644 --- a/test/e2e/test/kibana/builder.go +++ b/test/e2e/test/kibana/builder.go @@ -5,8 +5,8 @@ package kibana import ( - commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + commonv1beta1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1beta1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/test/e2e/test" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -56,7 +56,7 @@ func (b Builder) WithSuffix(suffix string) Builder { return b } -func (b Builder) WithElasticsearchRef(ref commonv1alpha1.ObjectSelector) Builder { +func (b Builder) WithElasticsearchRef(ref commonv1beta1.ObjectSelector) Builder { b.Kibana.Spec.ElasticsearchRef = ref return b } @@ -83,9 +83,9 @@ func (b Builder) WithNodeCount(count int) Builder { } func (b Builder) WithKibanaSecureSettings(secretNames ...string) Builder { - refs := make([]commonv1alpha1.SecretSource, 0, len(secretNames)) + refs := make([]commonv1beta1.SecretSource, 0, len(secretNames)) for i := range secretNames { - refs = append(refs, commonv1alpha1.SecretSource{SecretName: secretNames[i]}) + refs = append(refs, commonv1beta1.SecretSource{SecretName: secretNames[i]}) } b.Kibana.Spec.SecureSettings = refs return b diff --git a/test/e2e/test/kibana/checks_kb.go b/test/e2e/test/kibana/checks_kb.go index fd2fb3230c..29529aac8b 100644 --- a/test/e2e/test/kibana/checks_kb.go +++ b/test/e2e/test/kibana/checks_kb.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/name" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/pkg/errors" diff --git a/test/e2e/test/kibana/http_client.go b/test/e2e/test/kibana/http_client.go index 50736faa95..cc851a1e4d 100644 --- a/test/e2e/test/kibana/http_client.go +++ b/test/e2e/test/kibana/http_client.go @@ -13,14 +13,14 @@ import ( "net/url" "path" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/name" kbname "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/name" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/pkg/errors" ) -func NewKibanaClient(kb v1alpha1.Kibana, k *test.K8sClient) (*http.Client, error) { +func NewKibanaClient(kb v1beta1.Kibana, k *test.K8sClient) (*http.Client, error) { var caCerts []*x509.Certificate if kb.Spec.HTTP.TLS.Enabled() { crts, err := k.GetHTTPCerts(name.KBNamer, kb.Namespace, kb.Name) diff --git a/test/e2e/test/kibana/steps_creation.go b/test/e2e/test/kibana/steps_creation.go index cd025059b8..a949eccaed 100644 --- a/test/e2e/test/kibana/steps_creation.go +++ b/test/e2e/test/kibana/steps_creation.go @@ -7,7 +7,7 @@ package kibana import ( "testing" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" diff --git a/test/e2e/test/kibana/steps_init.go b/test/e2e/test/kibana/steps_init.go index 4162c647d1..ca8933dc53 100644 --- a/test/e2e/test/kibana/steps_init.go +++ b/test/e2e/test/kibana/steps_init.go @@ -7,7 +7,7 @@ package kibana import ( "testing" - kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" diff --git a/test/e2e/test/kibana/steps_mutation.go b/test/e2e/test/kibana/steps_mutation.go index 6561250418..db8ee818c6 100644 --- a/test/e2e/test/kibana/steps_mutation.go +++ b/test/e2e/test/kibana/steps_mutation.go @@ -7,7 +7,7 @@ package kibana import ( "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/test/e2e/test" "github.com/stretchr/testify/require" @@ -28,7 +28,7 @@ func (b Builder) UpgradeTestSteps(k *test.K8sClient) test.StepList { { Name: "Applying the Kibana mutation should succeed", Test: func(t *testing.T) { - var kb v1alpha1.Kibana + var kb v1beta1.Kibana require.NoError(t, k.Client.Get(k8s.ExtractNamespacedName(&b.Kibana), &kb)) kb.Spec = b.Kibana.Spec require.NoError(t, k.Client.Update(&kb))