Skip to content

Commit

Permalink
Add kubernetes-create-acr-secret template
Browse files Browse the repository at this point in the history
  • Loading branch information
NickGraham101 committed Dec 23, 2023
1 parent 5dabf45 commit ba5e9e2
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
parameters:
AzureSubscription:
ContainerRegistryAdminUser:
ContainerRegistryName:
ContainerRegistryPassword:
ClusterName:
Namespace:
ResourceGroup:
Condition: true

steps:
- task: Kubernetes@1
condition: and(${{ parameters.Condition }}, succeeded())
displayName: kubectl login
inputs:
connectionType: Azure Resource Manager
azureSubscriptionEndpoint: ${{ parameters.AzureSubscription }}
azureResourceGroup: ${{ parameters.ResourceGroup }}
kubernetesCluster: ${{ parameters.ClusterName }}
useClusterAdmin: true
command: login
- task: Kubernetes@1
condition: and(${{ parameters.Condition }}, succeeded())
continueOnError: true
displayName: kubectl delete ACR secret ${{ parameters.Namespace }}
inputs:
connectionType: Azure Resource Manager
azureSubscriptionEndpoint: ${{ parameters.AzureSubscription }}
azureResourceGroup: ${{ parameters.ResourceGroup }}
kubernetesCluster: ${{ parameters.ClusterName }}
useClusterAdmin: true
namespace: ${{ parameters.Namespace }}
command: delete
arguments: secret gandtsharedcr-cred
- task: Kubernetes@1
condition: and(${{ parameters.Condition }}, succeeded())
displayName: kubectl create ACR secret ${{ parameters.Namespace }}
inputs:
connectionType: Azure Resource Manager
azureSubscriptionEndpoint: ${{ parameters.AzureSubscription }}
azureResourceGroup: ${{ parameters.ResourceGroup }}
kubernetesCluster: ${{ parameters.ClusterName }}
useClusterAdmin: true
namespace: ${{ parameters.Namespace }}
command: create
arguments: secret docker-registry gandtsharedcr-cred --docker-server=${{ parameters.ContainerRegistryName }}.azurecr.io --docker-username=${{ parameters.ContainerRegistryAdminUser}} --docker-password=${{ parameters.ContainerRegistryPassword }}
- task: PowerShell@2
condition: and(${{ parameters.Condition }}, succeeded())
displayName: kubectl patch serviceaccount ${{ parameters.Namespace }}
inputs:
targetType: inline
script: >
kubectl patch serviceaccount default -n ${{ parameters.Namespace }} -p '{\"imagePullSecrets\": [{\"name\": \"gandtsharedcr-cred\"}]}'
pwsh: true

0 comments on commit ba5e9e2

Please sign in to comment.