Kubernetes Notes – 26 Sept 2023

DeamonSet
Statefulsets
Cron
Cronjob
Helm
-------
obs
monitoring
logging
============================
DeamonSet

Deamon
==============================
	deploy a pod
	Create 1 POD Per worker at max and at min.
			Logs Ex
			Metrices coll
			Monitoring
			Security
	desire == actual
=======================================
- kube proxy
- Canal

====================================================
====================================================
How to deploy PODS in k8?
----------------------------------------------------
POD
RC
RS
Deploy
DeamonSet
		POd
			1 POD each worker
			
Statefulsets
----------------------------

	k8
---------------------------
     50 worker

kubectl describe ds logging

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: logging
spec:
  selector:
    matchLabels:
      app: httpd-logging
  template:
    metadata:
      labels:
        app: httpd-logging
    spec:
      containers:
        - name: webserver
          image: httpd
          ports:
          - containerPort: 80



https://www.devopsschool.com/blog/explained-kubernetes-daemonset-with-example/
 2025  vi ds.yaml
 2026  kubectl apply -f ds.yaml
 2027  kubectl get ds
 2028  kubectl get nodes
 2029  kubectl get pods
 2030  kubectl delete pod logging-h7sgm
 2031  kubectl get pods

DaemonSet

StatefulSet example

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  serviceName: "web-service"
  replicas: 2
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web-container
        image: nginx:latest
        ports:
        - containerPort: 80
        volumeMounts:
        - name: data
          mountPath: /var/www/html  # Mount the volume at this path inside the container
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi
      storageClassName: manual 
DeamonSet
Statefulsets
job
Cronjob
Helm
-------
obs
monitoring
logging
============================
DeamonSet

Deamon
==============================
	deploy a pod
	Create 1 POD Per worker at max and at min.
			Logs Ex
			Metrices coll
			Monitoring
			Security
	desire == actual
=======================================
- kube proxy
- Canal

====================================================
====================================================
How to deploy PODS in k8?
----------------------------------------------------
POD
RC
RS
Deploy
DeamonSet
		POd
			1 POD each worker
			
Statefulsets
----------------------------

	k8
---------------------------
     50 worker

kubectl describe ds logging

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: logging
spec:
  selector:
    matchLabels:
      app: httpd-logging
  template:
    metadata:
      labels:
        app: httpd-logging
    spec:
      containers:
        - name: webserver
          image: httpd
          ports:
          - containerPort: 80



https://www.devopsschool.com/blog/explained-kubernetes-daemonset-with-example/
 2025  vi ds.yaml
 2026  kubectl apply -f ds.yaml
 2027  kubectl get ds
 2028  kubectl get nodes
 2029  kubectl get pods
 2030  kubectl delete pod logging-h7sgm
 2031  kubectl get pods
==========================================================
===========================================================
Statefulsets
	All the feature of Deploy
- Creating in order
	0 --1 --> 2 -> 3 -> 4
- Remmeber PV
	pod1 --> pv1
	pod2 --> pv2	 --> pv2
	pod3 --> pv3

	pod2 --> pv2

- Name is with pattern
	logging-arun-1
	logging-arun-2	
	logging-arun-3
- Deletion in order
	1 --> 2 -> 3 -> 4

pod-4324234324 --> pv1

pod-3424234234 --> pv1



apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  serviceName: "nginx"
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi


apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx


==========================================================
3 DB 

STATELESS - Deployment
STATEFULL - Statefulsets

=========================================================

job
Cronjob
======================================================


cmd 		---> Output -> Work
./script	---> Output -> Work





apiVersion: batch/v1
kind: Job
metadata:
  name: pi
spec:
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
  backoffLimit: 4


apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure


======================================================================================
====================================================================================
HPA = Horizontal Pod Autoscaling
==================================================
Deployment 
	10
	---
	svc
	----------
	'
kind: Horizontal Pod Autoscaling
-------------------------------
CMD - autoscale     Auto-scale a deployment, replica set, stateful set, or replication controller

=======================================================



kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://php-apache; done"

https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/

============================================================================================

CLIENT		------->  Registry/Repos

APT				Packages	
YUM				Packages
Nuget				Packages
Choclate
Playstore
appstore
======================================================

App			1 file [[[[ Hardcoding --- 
	deploy
	state
	configmap
	secret
	pv
	pvc
	hpa
	job
	cronjobs
	sa
	role
	rb
	cr
	clr

Web
	deploy
	state
	configmap
	secret
	pv
	pvc
	hpa
	job
	cronjobs
	sa
	role
	rb
	cr
	clr
DB
	deploy
	state
	configmap
	secret
	pv
	pvc
	hpa
	job
	cronjobs
	sa
	role
	rb
	cr
	clr

======================================
1 command install - update - remove
----------------------------------
package --- share 
Template
========================================================
			helm
--------------------------------------------
	chart == package (yaml) ===> Release




 2054  helm
 2055  curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
 2056  chmod 700 get_helm.sh
 2057  ./get_helm.sh
 2058  helm
 2059  clear
 2060  helm repo add bitnami https://charts.bitnami.com/bitnami
 2061  helm repo list
 2062  helm install my-apache bitnami/apache --version 10.1.2
 2063  helm list
 2064  kubectl get pods
 2065  helm upgrade my-apache bitnami/apache --version 10.1.2
 2066  kubectl get pods
 2067  helm list
 2068  helm
 2069  helm list
 2070  helm get my-apache
 2071  helm get my-apache all
 2072  helm get  all my-apache
 2073  kubectl get all
 2074  clear
 2075  helm
 2076  helm lst
 2077  helm list
 2078  helm uninstall my-apache
 2079  helm list
 2080  kubectl get pods
 2081  clear
 2082  ls
 2083  mkdir raju
 2084  cd raju/
 2085  slc
 2086  clear
 2087  ls
 2088  helm
 2089  clear
 2090  helm create web
 2091  tree
 2092  apt  install tree\
 2093  apt  install tree
 2094  clear
 2095  tree
 2096  helm install dsdsad ./web/
 2097  helm list
 2098  history























Subscribe
Notify of
guest

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

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x