Last active
March 28, 2021 15:44
-
-
Save davipviana/354cefc63b0f775bc2011411305df543 to your computer and use it in GitHub Desktop.
VM aks client init script
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
# variables | |
$vmUser = "" | |
$azSubscription = "" | |
$rgName = "" | |
$acrName = "" | |
$aksName = "" | |
# VM init | |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | |
sudo apt-get update | |
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io | |
sudo usermod -G docker $vmUser | |
docker run hello-world | |
# ACR login | |
az login | |
az account set --subscription $azSubscription | |
az acr login -n $acrName | |
# Getting and pushing image | |
az acr import -n $acrName --source docker.io/library/nginx:latest --image nginx:v1 | |
az acr repository list --name $acrName --output table | |
# Add image to AKS | |
sudo az aks install-cli | |
az aks get-credentials --resource-group $rgName --name $aksName | |
az aks check-acr --name $aksName --resource-group $rgName --acr $acrName.azurecr.io | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: nginx0-deployment | |
labels: | |
app: nginx0-deployment | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: | |
app: nginx0 | |
template: | |
metadata: | |
labels: | |
app: nginx0 | |
spec: | |
containers: | |
- name: nginx | |
image: $acrName.azurecr.io/nginx:v1 | |
ports: | |
- containerPort: 80 | |
kubectl apply -f acr-nginx.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment