DockerToken - Manage tokens for accessing Quay Container Registry repositories

The DockerToken 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 as https://quay.example.com:8443 for example.
  • validateCerts: Whether to allow insecure connections to the API. By default, insecure connections are refused.
  • 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. If token is set, then username is ignored.
  • password: The password to use for authenticating against the API. If token is set, then password is 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 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"
  token: vFYyU2D0fHYXvcA3Y5TYfMrIMyVIH9YmxoVLsmku

You refer to this secret in your DockerToken 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: DockerToken
metadata:
  name: dockertoken-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 dockertoken resource, but you can specify a different namespace.
    # namespace: mynamespace

  # Whether to preserve the corresponding Quay object when you
  # delete the resource.
  preserveInQuayOnDeletion: false

  name: mytoken

  # The Secret resource is created or updated, and stores the returned data.
  # You can use the secret as a pull secret so that pods can pull images from
  # Quay by using your credentials.
  # The secret contains the .dockerconfigjson entry, which is the Base64
  # encoded Docker configuration in JSON format
  retSecretRef:
    name: dockertoken-sample-ret-secret
    # By default, the operator stores the secret in the same namespace as the
    # dockertoken resource, but you can specify a different namespace.
    # namespace: mynamespace

Properties

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 DockerToken resource.

Type: string

Required: False

Default value: None

name

Name of the token to create or delete.

Type: string

Required: True

Default value: None

preserveInQuayOnDeletion

Whether to preserve the corresponding Quay object when you delete the DockerToken resource. When set to false (the default), the object is deleted from Quay.

Type: boolean

Required: False

Default value: False

retSecretRef

RetSecretRef is the secret resource that the DockerToken resource creates. This secret will store the data that the resource generates:

  • auth - Base64 encoding of the username and the token ('username:tokenCode``). Some client configuration files, such as the~/.docker/config.jsonDocker configuration file, require that you provide the username and the token in that format. You can decode the string by using thebase64 --decodecommand. See thebase64'(1) man page.
  • created - Token creation date and time.
  • dockerconfigjson - Base64 encoding of the ~/.docker/config.json configuration file. The containers-auth.json(5) man page describe the format of the file.
  • expiration - Expiration date and time of the token. By default, tokens do not expire. In that case expiration is null. Your Quay administrator might have activated expiration by setting the APP_SPECIFIC_TOKEN_EXPIRATION directive in the config.yaml configuration file.
  • lastAccessed - Last date and time the token was used. If the token has not been used yet, then lastAccessed is null.
  • name - Name of the application token.
  • tokenCode - Token to use as the password.
  • username - Username to use with client commands such as docker or podman. When you use a token with those commands, do not use your login name but use this username instead. For Quay, that username is always $app. Because the $ character is a special shell character, you might have to protect it with a backslash or by using single quotation marks.
  • uuid - Internal ID of the application token.

Type: object (see the following properties)

Required: False

Default value: None

retSecretRef.name

Name of the secret resource.

Type: string

Required: True

Default value: None

retSecretRef.namespace

Namespace of the secret resource. By default, the secret resource is created in the same namespace as the current DockerToken resource.

Type: string

Required: False

Default value: None

Listing the DockerToken Resources

You can retrieve the list of the DockerToken custom resources in a namespace by using the kubectl get command:

kubectl get dockertokens.quay.herve4m.github.io -n <namespace>