The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Kubernetes Continuous Deploy Plugin

kubernetesDeploy: Deploy to Kubernetes

  • configs (optional)

    The path patterns for the Kubernetes configurations you want to deploy, in the form of Ant glob syntax.

    • Type: String
  • credentialsType (optional)

    Choose how to get the kubeconfig file to authenticate with the Kubernetes cluster management endpoint.

    3 options are supported:

    1. Authenticate with Kube config file - Get the kubeconfig file from the workspace path.
    2. Fetch cluster details through SSH connection to the master node - Get the ~/.kube/config file through an SSH connection to the master node.
    3. Fill credentials details directly - Fill the contents in kubeconfig file directly.

    See also: Configure kubectl

    • Type: String
  • deleteResource (optional)

    Whether to delete the resource, if it is true, delete all resources in the config file.

    • Type: boolean
  • dockerCredentials (optional)
      Array / List of Nested Object
    • url
      URL to the Docker registry you are using. May be left blank to use the public DockerHub registry (currently https://index.docker.io/v1/).
      • Type: String
    • credentialsId
      • Type: String
  • enableConfigSubstitution (optional)

    Substitute variables (in the form $VARIABLE or ${VARIABLE}) in the configuration with values from Jenkins environment variables.

    This allows you to use dynamic values produced during the build in your Kubernetes configurations, e.g., a dynamically generated Docker image tag which will be used later in the deployment.

    • Type: boolean
  • kubeConfig (optional)
      Nested Object
    • path (optional)
      The kubeconfig file path relative to the current Jenkins workspace.
      • Type: String
  • kubeconfigId (optional)
    • Type: String
  • secretName (optional)
    The secret name that you can use in the Kubernetes Deployment configuration for the imagePullSecrets entry. Environment variable substitution are supported for the name input, so you can use available environment variables to construct the name dynamically, e.g., some-secret-$BUILD_NUMBER. The name should be in the pattern [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*, i.e., dot (.) concatenated sequences of hyphen (-) separated alphanumeric words. (See Kubernetes Names)

    If left blank, the plugin will generate a name based on the build name.

    The secret name will be exposed with the environment variable $KUBERNETES_SECRET_NAME. You can use this in your Kubernetes configuration to reference the updated secret when the "Enable Variable Substitution in Config" option is enabled.

    
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: nginx
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: some.private.registry.domain/nginx
            ports:
            - containerPort: 80
          imagePullSecrets:
          - name: $KUBERNETES_SECRET_NAME
    

    Note that once the secret is created, it will only be updated by the plugin. You have to manually delete it when it is not used anymore. If this is a problem, you may use fixed name so every time the job runs, the secret gets updated and no new secret is created.

    • Type: String
  • secretNamespace (optional)
    The Kubernetes namespace in which the secrets will be created with the credentials configured below.
    • Type: String
  • ssh (optional)
      Nested Object
    • sshCredentialsId (optional)
      The SSH login credentials. Can be:
      • Username with password, or
      • SSH Username with private key
      • Type: String
    • sshServer (optional)
      The SSH server address (<host>[:<port>]) of the Kubernetes master node. If port is omitted, the default SSH port 22 will be used.
      • Type: String
  • textCredentials (optional)
      Nested Object
    • certificateAuthorityData (optional)
      The clusters.cluster.certificate-authority-data value in the kubeconfig file.
      • Type: String
    • clientCertificateData (optional)
      The users.user.client-certificate-data value in the kubeconfig file.
      • Type: String
    • clientKeyData (optional)
      The users.user.client-key-data value in the kubeconfig file.
      • Type: String
    • serverUrl (optional)
      The clusters.cluster.server address in the kubeconfig. Generally, it should start with https://.
      • Type: String

step([$class: 'KubernetesDeploy']): Deploy to Kubernetes

  • context
      Nested Object
    • configs (optional)

      The path patterns for the Kubernetes configurations you want to deploy, in the form of Ant glob syntax.

      • Type: String
    • credentialsType (optional)

      Choose how to get the kubeconfig file to authenticate with the Kubernetes cluster management endpoint.

      3 options are supported:

      1. Authenticate with Kube config file - Get the kubeconfig file from the workspace path.
      2. Fetch cluster details through SSH connection to the master node - Get the ~/.kube/config file through an SSH connection to the master node.
      3. Fill credentials details directly - Fill the contents in kubeconfig file directly.

      See also: Configure kubectl

      • Type: String
    • deleteResource (optional)

      Whether to delete the resource, if it is true, delete all resources in the config file.

      • Type: boolean
    • dockerCredentials (optional)
        Array / List of Nested Object
      • url
        URL to the Docker registry you are using. May be left blank to use the public DockerHub registry (currently https://index.docker.io/v1/).
        • Type: String
      • credentialsId
        • Type: String
    • enableConfigSubstitution (optional)

      Substitute variables (in the form $VARIABLE or ${VARIABLE}) in the configuration with values from Jenkins environment variables.

      This allows you to use dynamic values produced during the build in your Kubernetes configurations, e.g., a dynamically generated Docker image tag which will be used later in the deployment.

      • Type: boolean
    • kubeConfig (optional)
        Nested Object
      • path (optional)
        The kubeconfig file path relative to the current Jenkins workspace.
        • Type: String
    • kubeconfigId (optional)
      • Type: String
    • secretName (optional)
      The secret name that you can use in the Kubernetes Deployment configuration for the imagePullSecrets entry. Environment variable substitution are supported for the name input, so you can use available environment variables to construct the name dynamically, e.g., some-secret-$BUILD_NUMBER. The name should be in the pattern [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*, i.e., dot (.) concatenated sequences of hyphen (-) separated alphanumeric words. (See Kubernetes Names)

      If left blank, the plugin will generate a name based on the build name.

      The secret name will be exposed with the environment variable $KUBERNETES_SECRET_NAME. You can use this in your Kubernetes configuration to reference the updated secret when the "Enable Variable Substitution in Config" option is enabled.

      
      apiVersion: extensions/v1beta1
      kind: Deployment
      metadata:
        name: nginx
      spec:
        replicas: 1
        template:
          metadata:
            labels:
              app: nginx
          spec:
            containers:
            - name: nginx
              image: some.private.registry.domain/nginx
              ports:
              - containerPort: 80
            imagePullSecrets:
            - name: $KUBERNETES_SECRET_NAME
      

      Note that once the secret is created, it will only be updated by the plugin. You have to manually delete it when it is not used anymore. If this is a problem, you may use fixed name so every time the job runs, the secret gets updated and no new secret is created.

      • Type: String
    • secretNamespace (optional)
      The Kubernetes namespace in which the secrets will be created with the credentials configured below.
      • Type: String
    • ssh (optional)
        Nested Object
      • sshCredentialsId (optional)
        The SSH login credentials. Can be:
        • Username with password, or
        • SSH Username with private key
        • Type: String
      • sshServer (optional)
        The SSH server address (<host>[:<port>]) of the Kubernetes master node. If port is omitted, the default SSH port 22 will be used.
        • Type: String
    • textCredentials (optional)
        Nested Object
      • certificateAuthorityData (optional)
        The clusters.cluster.certificate-authority-data value in the kubeconfig file.
        • Type: String
      • clientCertificateData (optional)
        The users.user.client-certificate-data value in the kubeconfig file.
        • Type: String
      • clientKeyData (optional)
        The users.user.client-key-data value in the kubeconfig file.
        • Type: String
      • serverUrl (optional)
        The clusters.cluster.server address in the kubeconfig. Generally, it should start with https://.
        • Type: String

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.