495 questions
Hello Diptesh Kumar,
You can parameterize the Kubernetes namespace in your DevOps YAML pipeline by using the parameters:
block at the top of the YAML file. This allows you to enter a namespace during runtime, with a default fallback (in my example default
).
example-
parameters:
- name: k8sNamespace
displayName: 'Kubernetes Namespace'
type: string
default: 'default'
variables:
imagePullSecret: acr-secret
dockerRegistryServiceConnection: myDockerRegistrySC
containerRegistry: acrk8stest2039.azurecr.io
imageRepository: demo
tag: latest
stages:
- stage: Deploy
jobs:
- job: DeployJob
steps:
- task: KubernetesManifest@0
displayName: 'Create imagePullSecret'
inputs:
action: createSecret
secretName: $(imagePullSecret)
namespace: ${{ parameters.k8sNamespace }}
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
- task: KubernetesManifest@0
displayName: 'Deploy App'
inputs:
action: deploy
namespace: ${{ parameters.k8sNamespace }}
manifests: |
$(Build.SourcesDirectory)/manifests/deployment.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)
Run the pipeline. it should trigger.
Reference links from MS