RepositoryImmutability - Manage tag immutability policies for repositories
The RepositoryImmutability custom resource relies on a Secret resource to provide the connection parameters to the Quay instance. This Secret resource must include the following data:
host: URL for accessing the Quay API, such ashttps://quay.example.com:8443for example.validateCerts: Whether to allow insecure connections to the API. By default, insecure connections are refused.timeout: Number of seconds to wait for Quay to send data before giving up. By default the timeout is at 10 seconds.token: OAuth access token for authenticating against the API. To create such a token see the Creating an OAuth Access Token documentation. You can also use the ApiToken custom resource to create this token.username: The username to use for authenticating against the API. Iftokenis set, thenusernameis ignored.password: The password to use for authenticating against the API. Iftokenis set, thenpasswordis ignored.
You can create the secret by using the kubectl create secret command:
kubectl create secret generic quay-credentials --from-literal host=https://quay.example.com:8443 --from-literal validateCerts=false --from-literal timeout=21 --from-literal token=vFYyU2D0fHYXvcA3Y5TYfMrIMyVIH9YmxoVLsmku
Or you can create the secret from a resource file:
---
apiVersion: v1
kind: Secret
metadata:
name: quay-credentials
stringData:
host: https://quay.example.com:8443
validateCerts: "false"
timeout: 21
token: vFYyU2D0fHYXvcA3Y5TYfMrIMyVIH9YmxoVLsmku
You refer to this secret in your RepositoryImmutability custom resource by using the connSecretRef property.
See the usage example.
Warning
Do not delete the Secret resource if a Quay custom resource still references it. If you delete the Secret resource, then the Operator cannot connect to the Quay API anymore, and cannot synchronize the Quay custom resource with its corresponding object in Quay. In addition, deleting the Quay custom resource does not complete because the Operator cannot delete the corresponding object in Quay.
If you face this issue, then edit the custom resource (kubectl edit), and set the .spec.preserveInQuayOnDeletion property to true.
Alternatively, you can remove the .metadata.finalizers section.
In both case, you must manually delete the corresponding object in Quay.
Usage Example
---
apiVersion: quay.herve4m.github.io/v1alpha1
kind: RepositoryImmutability
metadata:
name: repositoryimmutability-sample
spec:
# Connection parameters in a Secret resource
connSecretRef:
name: quay-credentials
# By default, the operator looks for the secret in the same namespace as
# the repositoryimmutability resource, but you can specify a different namespace.
# namespace: mynamespace
# Whether to preserve the corresponding Quay object when you
# delete the RepositoryImmutability resource.
preserveInQuayOnDeletion: false
repository: production/ubi9
tagPattern: "release-.*"
behavior: matching_immutable
Properties
behavior
Specify the behavior of the matching pattern. If matching_immutable, then tags that match the pattern are immutable. If not_matching_immutable, then all the tags not matching the pattern are immutable. matching_immutable by default.
Type: string
Required: False
Default value: None
connSecretRef
Reference to the secret resource that stores the connection parameters to the Quay Container Registry API.
The secret must include the host, token (or username and password), and optionally the validateCerts keys.
Type: object (see the following properties)
Required: True
Default value: None
connSecretRef.name
Name of the secret resource.
Type: string
Required: True
Default value: None
connSecretRef.namespace
Namespace of the secret resource. By default, the secret resource is retrieved from the same namespace as the current RepositoryImmutability resource.
Type: string
Required: False
Default value: None
newTagPattern
New regular expression for the immutability policy. Setting this option changes the regular expression of the policy which current pattern is provided in tagPattern.
Type: string
Required: False
Default value: None
preserveInQuayOnDeletion
Whether to preserve the corresponding Quay object when you delete the RepositoryImmutability resource. When set to false (the default), the object is deleted from Quay.
Type: boolean
Required: False
Default value: False
repository
Name of the existing repository to configure. The format for the name is namespace/shortname. The namespace can be an organization or your personal namespace. If you omit the namespace part in the name, then the resource looks for the repository in your personal namespace. You can manage tag immutability policies for repositories in your personal namespace, but not in the personal namespace of other users. The token you use in quayToken determines the user account you are using.
Type: string
Required: True
Default value: None
tagPattern
Regular expression to select the tags to protect.
Type: string
Required: True
Default value: None
Listing the RepositoryImmutability Resources
You can retrieve the list of the RepositoryImmutability custom resources in a namespace by using the kubectl get command:
kubectl get repositoryimmutabilities.quay.herve4m.github.io -n <namespace>