az aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 3
kubectl scale --replicas=3 deployment/test-app
az group create --name test-rg --location eastus
az aks create --resource-group test-rg --name testcluster --node-count 1 --enable-addons monitoring --generate-ssh-keys
kubectl
CLI: to manage the cluster: az aks install-cli --install-location=./kubectl
kubectl
to connect to your Kubernetes cluster, use az aks get-credentials --resource-group test-rg --name testcluster
kubectl get nodes
To deploy apache server you need a deployment yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-apache-app
spec:
replicas: 1
selector:
matchLabels:
app: test-app
template:
metadata:
labels:
apsps: test-app
spec:
containers:
- name: testappserver
image: httpd
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service # To expose the container to outside world
metadata:
name: test-app
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: test-app
kubectl apply -f app.yaml
kubectl create
kubectl get all
to see status of containers, services, replicas & deployment
kubectl get deployments
, kubectl get pods
kubectl get service test-app --watch
(--watch
flag to wait until it’s exposed to internet)ssh-keygen -t rsa -b 2048
az ad sp create-for-rbac --skip--asignment
appId
and password
-Select AKS template, e.g. quickstart 101-aksappId
and password
as service principal client id and service principal client secretaz create
creates a service principal automatically.
$HOME/.azure/aksServicePrincipal.json
on machine that run the commandaz ad sp create-for-rbac --skip-assignment --name myAKSClusterServicePrincipal
az aks create --resource-group myResourceGroup --name myAKSCluster --service-principal <appId> --client-secret <password>
az role assignment create --assignee <appId> --scope <resourceScope> --role Contributor
az aks install-connector
command
helm
(requires helm init
)az role assignment create
kubectl
command to deploy the file.APT
or Yum
for Linux)helm
for deploying the applicationhelm repo add
to add a repohelm repo update
to update chartshelm install
to run chartskubectl apply
Deploy a yaml file to create a service account using kubectl apply -f helm-rbac.yaml
:
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
helm init
helm init --service-account tiller --node-selectors "beta.kubernetes.io/os=linux"
helm install
nginx
container with helm:helm install stable/nginx-ingress --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux"
kubectl
configuration context, a user can run the az aks get-credentials
command