Operator throws error when cluster name is not valid
Summary
Cluster name that does not follow a specific validation pattern ([a-z]([-a-z0-9]*[a-z0-9])?
) produce errors in the operator and is not reconcilied.
Steps to reproduce
- Create a cluster named
1135
Expected Behaviour
Kubernetes should return an error that say "Cluster name must follow the pattern "a-z?""
Possible Solution
Add validation webhook to check that a cluster name follow the pattern [a-z]([-a-z0-9]*[a-z0-9])?
.
Environment
- StackGres version: 1.0.0-alpha4
- Kubernetes version: ?
- Cloud provider or hardware configuration: ?
Relevant logs and/or screenshots
021-06-14 12:51:28,177 ERROR [io.st.op.co.ClusterReconciliationCycle] (Cluster-ReconciliationCycle) StackGres Cluster default.1135 reconciliation failed: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://10.96.0.1/api/v1/namespaces
/default/services. Message: Service "1135-config" is invalid: metadata.name: Invalid value: "1135-config": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',
or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'). Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=metadata.name, message=Invalid value: "1135-config": a DNS-1035 label must consist of lower case alph
anumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'), reason=FieldValueInvalid, additionalProperties={})], group=null, kind=Service,
name=1135-config, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Service "1135-config" is invalid: metadata.name: Invalid value: "1135-config": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphab
etic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'), metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reaso
n=Invalid, status=Failure, additionalProperties={}).