Skip to content

kubernetesDeploy

Description

Deployment to Kubernetes test or production namespace within the specified Kubernetes cluster.

Deployment supports multiple deployment tools

Currently the following are supported:

Helm

Following helm command will be executed by default:

helm upgrade <deploymentName> <chartPath> --install --force --namespace <namespace> --wait --timeout <helmDeployWaitSeconds> --set "image.repository=<yourRegistry>/<yourImageName>,image.tag=<yourImageTag>,secret.dockerconfigjson=<dockerSecret>,ingress.hosts[0]=<ingressHosts[0]>,,ingress.hosts[1]=<ingressHosts[1]>,...
  • yourRegistry will be retrieved from containerRegistryUrl
  • yourImageName, yourImageTag will be retrieved from image
  • dockerSecret will be calculated with a call to kubectl create secret docker-registry regsecret --docker-server=<yourRegistry> --docker-username=<containerRegistryUser> --docker-password=<containerRegistryPassword> --dry-run=true --output=json'

Parameters

name mandatory default possible values
additionalParameters No
apiServer No
appTemplate No
chartPath Yes
containerRegistryPassword No
containerRegistrySecret No regsecret
containerRegistryUrl Yes
containerRegistryUser No
createDockerRegistrySecret No false true, false
deployTool No kubectl kubectl, helm, helm3
deploymentName Yes
dockerCredentialsId Yes
dockerEnvVars No deployTool=helm3: []
deployTool=helm: []
deployTool=kubectl: []
dockerImage No deployTool=helm3: dtzar/helm-kubectl:3.1.2
deployTool=helm: dtzar/helm-kubectl:2.12.1
deployTool=kubectl: dtzar/helm-kubectl:2.12.1
dockerOptions No deployTool=helm3: []
deployTool=helm: []
deployTool=kubectl: []
dockerWorkspace No deployTool=helm3: /config
deployTool=helm: /config
deployTool=kubectl: /config
helmDeployWaitSeconds No 300
image Yes
ingressHosts No
kubeConfig No
kubeConfigFileCredentialsId Yes
kubeContext No
kubeToken No
kubeTokenCredentialsId Yes
namespace No default
script Yes
stashContent No [deployDescriptor]
tillerNamespace No
verbose No false true, false
  • additionalParameters: Defines additional parameters for \"helm install\" or \"kubectl apply\" command.
  • apiServer: Defines the Url of the API Server of the Kubernetes cluster.
  • appTemplate: Defines the filename for the kubernetes app template (e.g. k8s_apptemplate.yaml)
  • chartPath: Defines the chart path for deployments using helm.
  • containerRegistryPassword: Password for container registry access - typically provided by the CI/CD environment.
  • containerRegistrySecret: Name of the container registry secret used for pulling containers from the registry.
  • containerRegistryUrl: http(s) url of the Container registry.
  • containerRegistryUser: Username for container registry access - typically provided by the CI/CD environment.
  • createDockerRegistrySecret: Toggle to turn on Regsecret creation with a \"deployTool:kubectl\" deployment.
  • deployTool: Defines the tool which should be used for deployment.
  • deploymentName: Defines the name of the deployment.
  • dockerEnvVars: Environment variables to set in the container, e.g. [http_proxy: "proxy:8080"].
  • dockerImage: Name of the docker image that should be used. If empty, Docker is not used and the command is executed directly on the Jenkins system.
  • dockerOptions: Docker options to be set when starting the container.
  • dockerWorkspace: Kubernetes only: Specifies a dedicated user home directory for the container which will be passed as value for environment variable HOME.
  • helmDeployWaitSeconds: Number of seconds before helm deploy returns.
  • image: Full name of the image to be deployed.
  • ingressHosts: List of ingress hosts to be exposed via helm deployment.
  • kubeConfig: Defines the path to the \"kubeconfig\" file.
  • kubeContext: Defines the context to use from the \"kubeconfig\" file.
  • kubeToken: Contains the id_token used by kubectl for authentication. Consider using kubeConfig parameter instead.
  • namespace: Defines the target Kubernetes namespace for the deployment.
  • script: The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, e.g. configuration parameters.
  • stashContent: Specific stashes that should be considered for the step execution.
  • tillerNamespace: Defines optional tiller namespace for deployments using helm.
  • verbose: verbose output

Step Configuration

We recommend to define values of step parameters via config.yml file.

In following sections of the config.yml the configuration is possible:

parameter general step/stage
additionalParameters X
apiServer X X
appTemplate X
chartPath X
containerRegistryPassword X
containerRegistrySecret X
containerRegistryUrl X X
containerRegistryUser X
createDockerRegistrySecret X
deployTool X
deploymentName X
dockerEnvVars X
dockerImage X
dockerOptions X
dockerWorkspace X
helmDeployWaitSeconds X
image X
ingressHosts X
kubeConfig X X
kubeContext X
kubeToken X X
namespace X
stashContent X
tillerNamespace X
verbose X

Exceptions

None

Examples

kubernetesDeploy script: this
// Deploy a helm chart called "myChart" using Helm 3
kubernetesDeploy script: this, deployTool: 'helm3', chartPath: 'myChart', deploymentName: 'myRelease', image: 'nginx', containerRegistryUrl: 'https://docker.io'