DevOps Classroom notes 14/Oct/2026

Loadblancer:

ELB

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: recreate-deployment-app
  labels:
    app: apache2
spec:
  replicas: 2
  selector:
    matchLabels:
      app: apache2
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: apache2
    spec:
      containers:
        - name: apache2
          image: httpd:2 # 2.4.69
          ports:
            - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: loadbalancer-service-recreate
  labels:
    app: apache2
spec:
  type: LoadBalancer
  selector:
    app: apache2
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Externalname:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-db
  labels:
    app: mysql
spec:
  replicas: 2
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - name: mysql
          image: mysql:latest
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "rootpassword"
          ports:
            - containerPort: 3306

---
apiVersion: v1
kind: Service
metadata:
  name: mysql-service
  labels:
    app: mysql
spec:
  type: ExternalName
  externalName: mysql.qt.com

Task:

  1. create deployment nop app and create loadblancer service for it
  2. create mysql demonset app and create externalname service for db
  3. configure db with external dns as host and test connection

Enviroment variables:

  1. Inline Enviroment variables
  2. load values form configmap (Non-sestive data)
  3. load values from secrets (cridentals, endpoints …etc)
env:
  - name: app_version
    value: 1.0
  - name: env
    value: prod
  - name: data_path
    value: "/temp"

EX:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nop-deployment-app
  labels:
    app: nop-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nop-app
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nop-app
    spec:
      containers:
        - name: nop-app
          image: nopcommerceteam/nopcommerce:latest
          ports:
            - containerPort: 5000
          env:
           - name: ASPNETCORE_ENVIRONMENT
             value: Development
           - name: ASPNETCORE_ENVIRONMENT=Production
             value: Production
           - name: DOTNET_PRINT_TELEMETRY_MESSAGE=false
             value: false
           - name: ASPNETCORE_URLS
             value: http://+:5000
           - name: DOTNET_RUNNING_IN_CONTAINER
             value: true
           - name: nop_version
             value: 4.90.8
           - name: aspnetcore
             value: 9.0
           - name: DOTNET_VERSION
             value: 9.0
           - name: ConnectionStrings__DataProvider
             value: MySql
           - name: ConnectionStrings__ConnectionString
             value: Server=mysql;Port=3306;Database=nopcommerce;Uid=nopuser;Pwd=noppassword;AllowUserVariables=True;


Configmap:

  • store data in key value pair
  • store non-senstive data
  • add json files also
# configmap
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  string-connection: "Server=mysql;Port=3306;Database=nopcommerce;Uid=nopuser;Pwd=noppassword;AllowUserVariables=True;"
  # Configuration data goes here
  config.json: |
    {
      "env": "production",
      "version": "2.0.1",
    }

secrets

kubectl create secret generic my-password --from-literal=username=admin --from-literal=password=secret123

cmd to convert secret to base64

echo -n "secret123" | base64 

# out put c2VjcmV0MTIz 

echo -n "c2VjcmV0MTIz" | base64 -d 
apiVersion: v1
data:
  password: c2VjcmV0MTIz # base64 
  username: YWRtaW4=
kind: Secret
metadata:
  name: my-password
  namespace: default
type: Opaque

login pod

kubectl exec -it <pod-name> -- /bin/bash
kubectl exec -it <pod-name> -- /bin/sh

kubectl exec -it <pod-name> -c <containername> -- /bin/bash
kubectl exec -it <pod-name> -c <containername> -- /bin/sh

echo $ConnectionStrings__DataProvider

Offical Docs for kubernetes

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube