docs/4-cloud-computing/4.3.6-aks.md | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
As eluded to in the previous section, ACI has limitations in terms of managing the deployment of many different containers. In this section we will take our simple Node.js application that we containerized in section 4.3.5 and deploy it to AKS.
Azure Kubernetes Service (AKS) is a container orchestration platform that addresses the needs of enterprise applications consisting of many containers that interoperate with each other, and an example of CaaS. It is a fully managed Kubernetes service offered by Microsoft.
-
Log into Azure CLI and select the correct subscription.
-
Create a resource group for AKS and associated resources.
-
Follow steps 1 through 12 from section 4.3.5, we will use the same container image, ACR instance and service principal for the following steps.
-
Create an AKS cluster using Azure CLI. Specify a node count of 1 and use the VM sku "Standard_B2s" for the node size. Assign the name of the cluster to environment variable CLUSTER_NAME.
-
Get credentials for your new AKS cluster.
az aks -h
-
Use Kubectl and confirm you can manage your new AKS cluster. You can also use Azure Portal to explore AKS cluster resources (namespaces, pods, ingress resources, etc..).
-
Use Kubectl to create a namespace for our Node.js application. Assign the name of the namespace to environment variable NAMESPACE.
-
Create a registry secret in the namespace so images can be pulled from ACR.
$SECRET_NAME
kubectl create secret docker-registry -h
?> In order to pull container images from a private Docker registry, a docker-registry secret must be created in the appropriate namespace. You will also need the docker server, username, and password.
- Deploy using Kubernetes manifests. In the interest of simplicity, we will expose our application via a Service of type LoadBalancer. Normally we would expose such applications via an Ingress resource using an Ingress Controller (e.g. NGINX).
apiVersion: apps/v1
kind: Deployment
metadata:
name: aks-bootcamp
namespace: $NAMESPACE
spec:
replicas: 1
selector:
matchLabels:
app: aks-bootcamp
template:
metadata:
labels:
app: aks-bootcamp
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
- name: aks-bootcamp
image: $DOCKER_SERVER/aci-bootcamp:v1
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 250m
memory: 256Mi
ports:
- containerPort: 3000
imagePullSecrets:
- name: $SECRET_NAME
---
apiVersion: v1
kind: Service
metadata:
name: aks-bootcamp
namespace: $NAMESPACE
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 3000
selector:
app: aks-bootcamp
kubectl apply -f /Users/YOUR_NAME/YAML_FILE
-
Use Kubectl to confirm the pods are running and then obtain the External IP for the Load Balancer and test the application using cURL.
-
Cleanup by deleting the resource group and the service principal.
- Can you explain the process of deploying a Node.js application to AKS? What are the key steps involved?
- Why is it necessary to create a docker-registry secret in the appropriate namespace in AKS, and what information is required to create this secret?
- Discuss the technologies involved in this process, such as Azure, Azure Kubernetes Service (AKS), Azure Container Registry (ACR), and Node.js. How do they integrate with each other to create the described solution?