Checkout Remote Github Branch

git fetch
git branch --track <name-of-branch> <name-of-remote:eg. origin>/<name-of-branch>
git switch <name-of-branch>

Caching Github credentials

Install prerequisites

Github CLI RHEL installation example

sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --addrepo https://cli.github/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli

Provide your login details

First create a PAT token in GH UI then:

gh auth login
  1. github.com
  2. https
  3. autheticate github cli: yes
  4. paste auth token
  5. Paste the PAT token you created here
  6. Live a calm and productive life

Installing AKS Helm Charts

Add a helm repo eg. azure marketplace

helm repo add azure-marketplace https://marketplace.azurecr.io/helm/v1/repo

Search for a helm file in the added local repos

helm search repo {filter keyword:optional}

Test a helm char (simulated)

helm install --debug --dry-run my-release ./chart-name

Install helm chart

helm install {values .yaml file to use:optional} my-release ./char-name

You can use a .tgz or repository-name/chart-name instead of ./char-name

Example output:

NAME: aks-store-demo
LAST DEPLOYED: Thu Jul 11 19:38:35 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

Query installed releases on cluster

helm list

To upgrade an existing release

helm upgrade my-app ./app-chart

This will only update the delta

Get manifest information for a release

helm get manifest aks-store-demo

Validate pod is deployed

kubectl get pods -o wide -w

Delete a helm release

helm delete aks-store-demo

Install helm chart with set values from cli

helm install --set replicaCount=5 aks-store-demo ./aks-store-demo

If a helm chart has "dependencies:" install them with

helm dependency build ./app-chart

Update dependency

helm dependency update ./app-chart

View helm deployment/upgrade history

helm history my-app

Roll back helm release

helm rollback my-app 2

Note: the "2" is referring to the revision output from "helm history ..."

Examples of using function, like if statements, in helm charts

Deleting an AKS resource

The simplest version is if you have everything in a dedicated resource group, in that case, delete the resource group then:

kubectl config delete-context aks-contoso-video

replace aks-contoso-video with whatever your app was called.

Example output:

deleted context aks-contoso-video from /home/user/.kube/config

Deploy to Azure Kubernetes Service Cluster (AKS)

This example is done using Azure Cloud Shell but you can just use azcli.

create deployment.yaml

# deployment.yaml
apiVersion: apps/v1 # api resource where this workload resides
kind: Deployment # kind of workload we are creating
metadata:
  name: contoso-website # name of deployment
spec:
  selector: # Define the wrapping strategy
    matchLabels: # Match all pods with the defined labels
      app: contoso-website # Labels follow the `name: value` template
  template: # This is the template of the pod inside the deployment
    metadata:
      labels: # allows deployments to find and group pods
        app: contoso-website
    spec:
      nodeSelector:
        kubernetes.io/os: linux
      containers: # this is where we define all containers
        - image: mcr.microsoft.com/mslearn/samples/contoso-website
          name: contoso-website
          resources: # specify minimum and max resources app is allowed to use from cluster
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 250m
              memory: 256Mi
          ports:
            - containerPort: 80 # this container exposes port 80
              name: http

Apply the Manifest

kubectl apply -f ./deployment.yaml

Example output: deployment.apps/contoso-website created

Check if deployment succeeded

kubectl get deploy contoso-website

Example output:

NAME              READY   UP-TO-DATE   AVAILABLE   AGE
contoso-website   0/1     1            0           16s

Check if pod running

kubectl get pods

Example output:

NAME                               READY   STATUS    RESTARTS   AGE
contoso-website-7c58c5f699-r79mv   1/1     Running   0          63s

First Previous 1 2 3 Next Last