Kubernetes part11
Class 96 Kubernetes Part8 August 24th
Step8:uninstall the deployment
Kubernetes part11
Class 96 Kubernetes Part8 August 24th
Kubernetes part10
Class 95 Kubernetes Part8 August 23rd
Functionality How it will work:
- context:
cluster: minikube
name: context_info
user: minikube
name: minikube
- context:
cluster: minikube
user: subbu
name: my-context
Kubernetes part9
Class 94 Kubernetes Part8 August 22nd
Resource Quota: Resource quota is on of the rich features of Kubernetes that helps to manage and distribute resources according to the requirements.
There are tow type of restrictions that need to be mentioned while using resource quota
Limit: Represent the maximum amount of CPUS or memory the pod can use
(limit: 4 cpus & 4 gb ram)
Request: Represent the minimum amount of CPU or memory that the pod is guaranteed to have
(Pod creation minimum requirement 1cpu & 1 gb ram)
Practical:
Step1: minikube already setup done ec2-instance amazon Linux
[root@ip-10-0-0-29 ~]# systemctl start docker
[root@ip-10-0-0-29 ~]# minikube start --driver=docker --force
[root@ip-10-0-0-29 ~]# minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Step2:Create namespace and going to inside the namespace
[root@ip-10-0-0-29 ~]# kubectl create ns dev
namespace/dev created
[root@ip-10-0-0-29 ~]# kubectl config set-context --current --namespace=dev
Context "minikube" modified.
Step3: As you see here Create resource
[root@ip-10-0-0-29 ~]# vi resourcequote.yaml
[root@ip-10-0-0-29 ~]# cat resourcequote.yaml
apiVersion: v1
kind: Pod
metadata:
name: team-a
spec:
containers:
- name: container1
image: nginx
ports:
- containerPort: 80
resources:
requests:
memory: "10Mi"
cpu: "100m"
limits:
memory: "20Mi"
cpu: "200m"
[root@ip-10-0-0-29 ~]# kubectl create -f resourcequote.yaml
pod/team-a created
Step3: As see below namespace is dev and for the pod created with 100mi memory 10 mi
apiVersion: v1
kind: Pod
metadata:
name: team-c
spec:
containers:
- name: container1
image: nginx
ports:
- containerPort: 80
resources:
requests:
memory: "10Mi"
cpu: "100m"
pod/team-c created
As see below request given it will take request only , no limit that mean it is unlimited , it is not good practice
[root@ip-10-0-0-29 ~]# kubectl describe po team-c
Name: team-c
Namespace: dev
Priority: 0
Service Account: default
Node: minikube/192.168.49.2
Requests:
cpu: 100m
memory: 10Mi
Environment: <none>
Mounts:
[root@ip-10-0-0-29 ~]# kubectl get ns
NAME STATUS AGE
default Active 4d
dev Active 3h58m
As see below showing how many cpu 1, you able create memory
[root@ip-10-0-0-29 ~]# kubectl describe ns dev
Name: dev
Labels: kubernetes.io/metadata.name=dev
Annotations: <none>
Status: Active
Resource Quotas
Name: myreq
Resource Used Hard
-------- --- ---
limits.cpu 0 1
limits.memory 0 1500Mi
requests.cpu 0 258m
requests.memory 0 500Mi
No LimitRange resource.
[root@ip-10-0-0-29 ~]# kubectl apply -f realtime.yaml
Warning: resource resourcequotas/myreq is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
resourcequota/myreq configured
--See below resource quota increased
Kubernetes part8
Class 93 Kubernetes Part8 August 21st
Topic: Config maps ,Secrete
Config maps : non-sensitive information pod (container):
We will create config map file like this{port:300 , url:myql.com } attached to pod using those key pair value container will use them.
Secrets: sensitive information user and password , Secrets(encrypt)-->pod(container)
How many ways to CM will create
1.Literal(through CLI)
2.env-file
3.folder(not using)
(above two imperative)
4. manifest file (Declarative )
Practical:
Step1: Create one Ec2 machine amazon linux C7i-flex-large 25 Gb
Minikube installation
[root@ip-10-0-0-29 ~]# curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
[root@ip-10-0-0-29 bin]# chmod 777 minikube
[root@ip-10-0-0-29 bin]# minikube version
minikube version: v1.36.0
commit: f8f52f5de11fc6ad8244afac475e1d0f96841df1-dirty
[root@ip-10-0-0-29 bin]#
Docker Installation
[root@ip-10-0-0-29 bin]# systemctl start docker
[root@ip-10-0-0-29 bin]# minikube start --driver=docker --force
[root@ip-10-0-0-29 bin]# minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
[root@ip-10-0-0-29 bin]# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 138 100 138 0 0 1240 0 --:--:-- --:--:-- --:--:-- 1243
100 57.3M 100 57.3M 0 0 114M 0 --:--:-- --:--:-- --:--:-- 126M
-rwxrwxrwx. 1 root root 132766301 Aug 21 18:09 minikube
-rw-r--r--. 1 root root 60129464 Aug 21 18:18 kubectl
[root@ip-10-0-0-29 bin]# chmod +x kubectl
[root@ip-10-0-0-29 bin]# kubectl version
Client Version: v1.33.4
Kustomize Version: v5.6.0
Server Version: v1.33.1
Step2: Below one is by default config map file
[root@ip-10-0-0-29 bin]# kubectl get cm
NAME DATA AGE
kube-root-ca.crt 1 16m
Step3: using literal create one configmap file
[root@ip-10-0-0-29 bin]# kubectl create cm mycm1 --from-literal name=subbu --from-literal course=Devops --from-literal cloud=aws
configmap/mycm1 created
[root@ip-10-0-0-29 bin]# kubectl get cm
NAME DATA AGE
kube-root-ca.crt 1 22m
mycm1 3 10s
[root@ip-10-0-0-29 bin]# kubectl create cm mycm2 --from-literal company=tcs --from-literal project=swiggy
configmap/mycm2 created
[root@ip-10-0-0-29 ~]# kubectl create -f manifest.yaml
pod/pod-1 created
[root@ip-10-0-0-29 ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
pod-1 1/1 Running 0 9s
-- Go to inside the pod
root@pod-1:/# printenv
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_PORT=443
HOSTNAME=pod-1
PWD=/
person=subbu
PKG_RELEASE=1~bookworm
secondvalue=aws
HOME=/root
KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443
client=swiggy
DYNPKG_RELEASE=1~bookworm
NJS_VERSION=0.9.1
TERM=xterm
SHLVL=1
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1
KUBERNETES_SERVICE_HOST=10.96.0.1
KUBERNETES_PORT=tcp://10.96.0.1:443
KUBERNETES_PORT_443_TCP_PORT=443
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NGINX_VERSION=1.29.1
NJS_RELEASE=1~bookworm
_=/usr/bin/printenv
2.env-file
Step1: Create one env file
[root@ip-10-0-0-29 ~]# vi one.env
[root@ip-10-0-0-29 ~]# cat one.env
app=swiggy
env=dev
team=devops
api=http://www.amazon.com
port:3000
Step2:Create configmap one config file we have place maximum size 1 MB for one config map file,
if required more then that kubernete volume we can use.
[root@ip-10-0-0-29 ~]# kubectl create cm amazon --from-env-file=one.env
configmap/amazon created
[root@ip-10-0-0-29 ~]# kubectl get secret mysec1 -o yaml
apiVersion: v1
data:
password: YWRtaW4xMjM=
username: c3ViYnU=
kind: Secret
metadata:
creationTimestamp: "2025-08-21T19:52:34Z"
name: mysec1
namespace: default
resourceVersion: "4999"
uid: d0dcb7ed-897d-4e12-bc79-21d9c171950e
type: Opaque