github.com/jaylevin/jenkins-library@v1.230.4/resources/metadata/kubernetesDeploy.yaml (about) 1 metadata: 2 name: kubernetesDeploy 3 aliases: 4 - name: deployToKubernetes 5 deprecated: true 6 description: Deployment to Kubernetes test or production namespace within the specified Kubernetes cluster. 7 longDescription: |- 8 Deployment to Kubernetes test or production namespace within the specified Kubernetes cluster. 9 10 !!! note "Deployment supports multiple deployment tools" 11 Currently the following are supported: 12 13 * [Helm](https://helm.sh/) command line tool and [Helm Charts](https://docs.helm.sh/developing_charts/#charts). 14 * [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) and `kubectl apply` command. 15 16 ## Helm 17 Following helm command will be executed by default: 18 19 ``` 20 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]>,... 21 ``` 22 23 * `yourRegistry` will be retrieved from `containerRegistryUrl` 24 * `yourImageName`, `yourImageTag` will be retrieved from `image` 25 * `dockerSecret` will be calculated with a call to `kubectl create secret generic <containerRegistrySecret> --from-file=.dockerconfigjson=<dockerConfigJson> --type=kubernetes.io/dockerconfigjson --insecure-skip-tls-verify=true --dry-run=client --output=json` 26 spec: 27 inputs: 28 secrets: 29 - name: kubeConfigFileCredentialsId 30 description: Jenkins 'Secret file' credentials ID containing kubeconfig file. Details can be found in the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/). 31 aliases: 32 - name: kubeCredentialsId 33 deprecated: true 34 type: jenkins 35 - name: kubeTokenCredentialsId 36 description: Jenkins 'Secret text' credentials ID containing token to authenticate to Kubernetes. This is an alternative way to using a kubeconfig file. Details can be found in the [Kubernetes documentation](https://kubernetes.io/docs/reference/access-authn-authz/authentication/). 37 aliases: 38 - name: k8sTokenCredentialsId 39 deprecated: true 40 type: jenkins 41 - name: dockerCredentialsId 42 type: jenkins 43 - name: dockerConfigJsonCredentialsId 44 description: Jenkins 'Secret file' credentials ID containing Docker config.json (with registry credential(s)). 45 type: jenkins 46 resources: 47 - name: deployDescriptor 48 type: stash 49 params: 50 - name: additionalParameters 51 aliases: 52 - name: helmDeploymentParameters 53 type: "[]string" 54 description: Defines additional parameters for "helm install" or "kubectl apply" command. 55 scope: 56 - PARAMETERS 57 - STAGES 58 - STEPS 59 - name: apiServer 60 aliases: 61 - name: k8sAPIServer 62 type: string 63 description: Defines the Url of the API Server of the Kubernetes cluster. 64 scope: 65 - GENERAL 66 - PARAMETERS 67 - STAGES 68 - STEPS 69 - name: appTemplate 70 aliases: 71 - name: k8sAppTemplate 72 type: string 73 description: Defines the filename for the kubernetes app template (e.g. k8s_apptemplate.yaml). 74 longDescription: | 75 There are two supported ways for the template rendering: 76 77 1. For a deployments using single image, you can use a placeholder `<image-name>`, which will be replaced with the image GUN. 78 ``` 79 apiVersion: apps/v1 80 kind: Deployment 81 metadata: 82 name: app 83 labels: 84 app: app 85 spec: 86 replicas: 3 87 selector: 88 matchLabels: 89 app: app 90 template: 91 metadata: 92 labels: 93 app: app 94 spec: 95 containers: 96 - name: app 97 image: <image-name> 98 ``` 99 100 2. Helm styled templates, with the support for multi-image deployments. 101 102 ``` 103 apiVersion: apps/v1 104 kind: Deployment 105 metadata: 106 name: app 107 labels: 108 app: app 109 spec: 110 replicas: 3 111 selector: 112 matchLabels: 113 app: app 114 template: 115 metadata: 116 labels: 117 app: app 118 spec: 119 containers: 120 - name: app-1 121 image: "{{ .Values.image.repository}}:{{ .Values.image.tag }}" 122 - name: app-2 123 image: "{{ .Values.image.app_2.repository}}:{{ .Values.image.app_2.tag }}" 124 ``` 125 scope: 126 - PARAMETERS 127 - STAGES 128 - STEPS 129 - name: chartPath 130 aliases: 131 - name: helmChartPath 132 type: string 133 description: Defines the chart path for deployments using helm. It is a mandatory parameter when `deployTool:helm` or `deployTool:helm3`. 134 scope: 135 - PARAMETERS 136 - STAGES 137 - STEPS 138 - name: containerRegistryPassword 139 description: Password for container registry access - typically provided by the CI/CD environment. 140 type: string 141 scope: 142 - PARAMETERS 143 - STAGES 144 - STEPS 145 secret: true 146 resourceRef: 147 - name: dockerCredentialsId 148 type: secret 149 param: password 150 - name: commonPipelineEnvironment 151 param: container/repositoryPassword 152 - name: commonPipelineEnvironment 153 param: custom/repositoryPassword 154 - name: containerImageName 155 aliases: 156 - name: dockerImageName 157 type: string 158 description: Name of the container which will be built - will be used together with `containerImageTag` instead of parameter `containerImage` 159 scope: 160 - GENERAL 161 - PARAMETERS 162 - STAGES 163 - STEPS 164 - name: containerImageTag 165 aliases: 166 - name: artifactVersion 167 type: string 168 description: Tag of the container which will be built - will be used together with `containerImageName` instead of parameter `containerImage` 169 scope: 170 - GENERAL 171 - PARAMETERS 172 - STAGES 173 - STEPS 174 resourceRef: 175 - name: commonPipelineEnvironment 176 param: artifactVersion 177 - name: containerRegistryUrl 178 aliases: 179 - name: dockerRegistryUrl 180 type: string 181 description: http(s) url of the Container registry where the image to deploy is located. 182 resourceRef: 183 - name: commonPipelineEnvironment 184 param: container/registryUrl 185 scope: 186 - GENERAL 187 - PARAMETERS 188 - STAGES 189 - STEPS 190 mandatory: true 191 - name: containerRegistryUser 192 description: Username for container registry access - typically provided by the CI/CD environment. 193 type: string 194 scope: 195 - PARAMETERS 196 - STAGES 197 - STEPS 198 secret: true 199 resourceRef: 200 - name: dockerCredentialsId 201 type: secret 202 param: username 203 - name: commonPipelineEnvironment 204 param: container/repositoryUsername 205 - name: commonPipelineEnvironment 206 param: custom/repositoryUsername 207 - name: containerRegistrySecret 208 description: Name of the container registry secret used for pulling containers from the registry. 209 longDescription: |- 210 Name of the container registry secret used for pulling containers from the registry. 211 212 **For `deployTool: helm/helm3`:**<br /> 213 If `containerRegistryUser` and `containerRegistryPassword` are provided, a secret is created on the fly and the information is passed to the helm template.<br /> 214 215 **For `deployTool: kubectl`:**<br /> 216 If `containerRegistryUser` and `containerRegistryPassword` are provided, a secret with the given name will be created in the Kubernetes cluster. 217 218 If neither `containerRegistryUser` nor `containerRegistryPassword` are provided, it is expected that a secret with the configured name exists in the target Kubernetes cluster.<br /> 219 type: string 220 scope: 221 - PARAMETERS 222 - STAGES 223 - STEPS 224 default: regsecret 225 - name: createDockerRegistrySecret 226 type: bool 227 description: "Only for `deployTool:kubectl`: Toggle to turn on `containerRegistrySecret` creation." 228 scope: 229 - PARAMETERS 230 - STAGES 231 - STEPS 232 default: false 233 - name: deploymentName 234 aliases: 235 - name: helmDeploymentName 236 type: string 237 description: Defines the name of the deployment. It is a mandatory parameter when `deployTool:helm` or `deployTool:helm3`. 238 scope: 239 - PARAMETERS 240 - STAGES 241 - STEPS 242 - name: deployTool 243 type: string 244 description: Defines the tool which should be used for deployment. 245 mandatory: true 246 scope: 247 - PARAMETERS 248 - STAGES 249 - STEPS 250 default: kubectl 251 possibleValues: 252 - kubectl 253 - helm 254 - helm3 255 - name: forceUpdates 256 aliases: 257 - name: force 258 type: bool 259 description: "Adds `--force` flag to a helm resource update command or to a kubectl replace command" 260 mandatory: false 261 scope: 262 - PARAMETERS 263 - STAGES 264 - STEPS 265 default: true 266 - name: helmDeployWaitSeconds 267 type: int 268 description: Number of seconds before helm deploy returns. 269 scope: 270 - PARAMETERS 271 - STAGES 272 - STEPS 273 default: 300 274 - name: helmValues 275 type: "[]string" 276 description: List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`) 277 scope: 278 - PARAMETERS 279 - STAGES 280 - STEPS 281 - name: valuesMapping 282 type: "map[string]interface{}" 283 longDescription: | 284 Mapping of values provided by Piper onto custom paths in format `[custom-path]: [piper-value]` 285 286 Example: 287 ```yaml 288 valuesMapping: 289 subchart.image.tag: image.debug.tag 290 subchart.image.repository: image.debug.repository 291 subchart.image.pullsecret: secret.dockerconfigjson 292 ``` 293 scope: 294 - PARAMETERS 295 - STAGES 296 - STEPS 297 - name: image 298 aliases: 299 - name: deployImage 300 type: string 301 description: Full name of the image to be deployed. 302 resourceRef: 303 - name: commonPipelineEnvironment 304 param: container/imageNameTag 305 mandatory: true 306 scope: 307 - PARAMETERS 308 - STAGES 309 - STEPS 310 - name: imageNames 311 type: "[]string" 312 description: List of names of the images to be deployed. 313 resourceRef: 314 - name: commonPipelineEnvironment 315 param: container/imageNames 316 scope: 317 - PARAMETERS 318 - STAGES 319 - STEPS 320 - name: imageNameTags 321 type: "[]string" 322 description: List of full names (registry and tag) of the images to be deployed. 323 resourceRef: 324 - name: commonPipelineEnvironment 325 param: container/imageNameTags 326 scope: 327 - PARAMETERS 328 - STAGES 329 - STEPS 330 - name: imageDigests 331 type: "[]string" 332 description: List of image digests of the images to be deployed, in the format `sha256:<hash>`. If provided, image digests will be appended to the image tag, e.g. `<repository>/<name>:<tag>@<digest>` 333 resourceRef: 334 - name: commonPipelineEnvironment 335 param: container/imageDigests 336 scope: 337 - PARAMETERS 338 - STAGES 339 - STEPS 340 - name: ingressHosts 341 type: "[]string" 342 description: (Deprecated) List of ingress hosts to be exposed via helm deployment. 343 longDescription: |- 344 **DEPRECATED**<br /> 345 List of ingress hosts to be exposed via helm deployment.<br /> 346 Host names are passed to helm template via ingress configuration.<br /> 347 This requires a modification to the default helm template, thus it is not recommended. 348 349 Recommendation is to use custom values and pass them via parameter `helmValues`.<br /> 350 Since helm supports multiple files on top of the `values.yaml`, landscape-specific attributes can be passed via a specific file. 351 scope: 352 - PARAMETERS 353 - STAGES 354 - STEPS 355 - name: keepFailedDeployments 356 type: bool 357 description: Defines whether a failed deployment will be purged 358 default: false 359 scope: 360 - GENERAL 361 - PARAMETERS 362 - STAGES 363 - STEPS 364 - name: runHelmTests 365 type: bool 366 description: Defines whether or not to run helm tests against the recently deployed release 367 default: false 368 scope: 369 - GENERAL 370 - PARAMETERS 371 - STAGES 372 - STEPS 373 - name: showTestLogs 374 type: bool 375 description: Defines whether to print the pod logs after running helm tests 376 default: false 377 scope: 378 - GENERAL 379 - PARAMETERS 380 - STAGES 381 - STEPS 382 - name: kubeConfig 383 type: string 384 description: Defines the path to the "kubeconfig" file. 385 scope: 386 - GENERAL 387 - PARAMETERS 388 - STAGES 389 - STEPS 390 secret: true 391 resourceRef: 392 - name: kubeConfigFileCredentialsId 393 type: secret 394 - type: vaultSecretFile 395 name: kubeConfigFileVaultSecretName 396 default: kube-config 397 - name: kubeContext 398 type: string 399 description: Defines the context to use from the "kubeconfig" file. 400 scope: 401 - PARAMETERS 402 - STAGES 403 - STEPS 404 - name: kubeToken 405 type: string 406 description: Contains the id_token used by kubectl for authentication. Consider using kubeConfig parameter instead. 407 scope: 408 - GENERAL 409 - PARAMETERS 410 - STAGES 411 - STEPS 412 secret: true 413 resourceRef: 414 - name: kubeTokenCredentialsId 415 type: secret 416 - name: namespace 417 aliases: 418 - name: helmDeploymentNamespace 419 - name: k8sDeploymentNamespace 420 type: string 421 description: Defines the target Kubernetes namespace for the deployment. 422 scope: 423 - PARAMETERS 424 - STAGES 425 - STEPS 426 default: default 427 - name: tillerNamespace 428 aliases: 429 - name: helmTillerNamespace 430 type: string 431 description: Defines optional tiller namespace for deployments using helm. 432 scope: 433 - PARAMETERS 434 - STAGES 435 - STEPS 436 - name: dockerConfigJSON 437 type: string 438 description: Path to the file `.docker/config.json` - this is typically provided by your CI/CD system. You can find more details about the Docker credentials in the [Docker documentation](https://docs.docker.com/engine/reference/commandline/login/). 439 scope: 440 - PARAMETERS 441 - STAGES 442 - STEPS 443 secret: true 444 default: '.pipeline/docker/config.json' 445 resourceRef: 446 - name: dockerConfigJsonCredentialsId 447 type: secret 448 - type: vaultSecretFile 449 name: dockerConfigFileVaultSecretName 450 default: docker-config 451 - name: deployCommand 452 type: string 453 description: "Only for `deployTool: kubectl`: defines the command `apply` or `replace`. The default is `apply`." 454 mandatory: false 455 scope: 456 - PARAMETERS 457 - STAGES 458 - STEPS 459 default: apply 460 possibleValues: 461 - apply 462 - replace 463 containers: 464 - image: dtzar/helm-kubectl:3.8.1 465 workingDir: /config 466 options: 467 - name: -u 468 value: "0" 469 conditions: 470 - conditionRef: strings-equal 471 params: 472 - name: deployTool 473 value: helm3 474 - image: dtzar/helm-kubectl:2.17.0 475 workingDir: /config 476 options: 477 - name: -u 478 value: "0" 479 conditions: 480 - conditionRef: strings-equal 481 params: 482 - name: deployTool 483 value: helm 484 - image: dtzar/helm-kubectl:2.17.0 485 workingDir: /config 486 options: 487 - name: -u 488 value: "0" 489 conditions: 490 - conditionRef: strings-equal 491 params: 492 - name: deployTool 493 value: kubectl