Last active
April 19, 2019 13:00
-
-
Save mohcinemadkour/eb0cedbd395755839e2e3cb1980e611b to your computer and use it in GitHub Desktop.
The Azure Kubernetes Workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App Insights: 8de2bc6e-8885-43c4-892d-ba8440bb6026 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$AKS_RESOURCE_GROUP="akschallenge" | |
$AKS_CLUSTER_NAME="aks-workshop-lra" | |
$ACR_RESOURCE_GROUP="akschallenge" | |
$ACR_NAME="acraksworkshoplra" | |
$SERVICE_PRINCIPAL_NAME="aks-workshop-lra" | |
# Populate the ACR login server and resource id. | |
$ACR_LOGIN_SERVER=$(az acr show --name $ACR_NAME --query loginServer --output tsv) | |
$ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query id --output tsv) | |
# Create acrpull role assignment with a scope of the ACR resource. | |
$SP_PASSWD=$(az ad sp create-for-rbac --name http://$SERVICE_PRINCIPAL_NAME --role acrpull --scopes $ACR_REGISTRY_ID --query password --output tsv) | |
# Get the service principal client id. | |
$CLIENT_ID=$(az ad sp show --id http://$SERVICE_PRINCIPAL_NAME --query appId --output tsv) | |
# Output used when creating Kubernetes secret. | |
echo "Service principal ID: $CLIENT_ID" | |
echo "Service principal password: $SP_PASSWD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
az acr login -n acraksworkshoplra | |
az acr update -n acraksworkshoplra --admin-enabled true | |
az acr credential show -n acraksworkshoplra | |
# login using ACR built-in account | |
docker login myregistry.azurecr.io -u acraksworkshoplra -p [PASSWORD FROM PREVIOUS COMMAND] | |
# login using AKS generated SPN | |
docker login acraksworkshoplra.azurecr.io -u [app_id] -p [app_secret] | |
docker build -f Dockerfile -t acraksworkshoplra.azurecr.io/captureorder . | |
docker tag acraksworkshoplra.azurecr.io/captureorder acraksworkshoplra.azurecr.io/captureorder:1.0 | |
docker push acraksworkshoplra.azurecr.io/captureorder:1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pool: | |
vmImage: 'Ubuntu 16.04' | |
steps: | |
- task: CopyFiles@2 | |
displayName: 'copy yaml files' | |
inputs: | |
sourceFolder: 'yaml' | |
contents: '**' | |
targetFolder: '$(Build.ArtifactStagingDirectory)/yaml' | |
- task: CopyFiles@2 | |
displayName: 'copy helm files' | |
inputs: | |
sourceFolder: '$(System.DefaultWorkingDirectory)/helm' | |
contents: '**/*' | |
targetFolder: '$(Build.ArtifactStagingDirectory)/helm' | |
- task: PublishBuildArtifacts@1 | |
displayName: 'publish artifacts' | |
inputs: | |
artifactName: 'deploy' | |
pathToPublish: '$(Build.ArtifactStagingDirectory)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pool: | |
vmImage: 'Ubuntu 16.04' | |
variables: | |
imageName: '$(acrName).azurecr.io/captureorder' | |
imageTag: '$(imageName):$(Build.BuildNumber)' | |
# define three more variables acrName, dockerId and dockerPassword in the build pipeline in UI | |
steps: | |
- script: docker build -f Dockerfile -t $(imageName) . | |
displayName: 'docker build' | |
- script: docker login $(acrName).azurecr.io -u $(dockerId) -p $(dockerPassword) | |
displayName: 'docker login' | |
- script: docker tag $(imageName) $(imageTag) | |
displayName: 'docker tag' | |
- script: docker push $(imageTag) | |
displayName: 'docker push' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl exec -it orders-mongo-mongodb-599756bb95-qr7dq -- /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment