In my current setup deployment configured to maintain 2 pod, i want to make that into 1 pod
PS C:\Users\booba> kubectl.exe edit deployment my-microservice -n akilan
//now it will open a notepad with configuration
changing the replicas:2 #to 1
//just edit and save the notepad and close, it will reflect .
PS C:\Users\booba> kubectl.exe edit deployment my-microservice -n
akilan
deployment.apps/my-microservice edited
PS C:\Users\booba>
///another way to modify the setup
//find the yaml file of the setup and make a new copy of the file and edit them and apply to modify the setup
//view the current yaml file of the deployement
PS C:\Users\booba> kubectl.exe -n akilan get deployment my-microse
rvice -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"ann
otations":{},"name":"my-microservice","namespace":"akilan"},"spec"
:{"replicas":2,"selector":{"matchLabels":{"run":"my-microservice"}
},"template":{"metadata":{"labels":{"run":"my-microservice"}},"spe
c":{"containers":[{"image":"nginx:latest","name":"my-microservice"
,"ports":[{"containerPort":8080}]}]}}}}
creationTimestamp: "2024-05-18T14:50:41Z"
generation: 3
name: my-microservice
namespace: akilan
resourceVersion: "96365"
uid: e7cfd541-336b-42ba-aea0-66e767e42091
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
run: my-microservice
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2024-08-11T16:26:24Z"
creationTimestamp: null
labels:
run: my-microservice
spec:
containers:
- image: nginx:latest
imagePullPolicy: Always
name: my-microservice
ports:
- containerPort: 8080
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 2
conditions:
- lastTransitionTime: "2024-05-18T14:50:44Z"
lastUpdateTime: "2024-05-18T14:51:25Z"
message: ReplicaSet "my-microservice-6448c89947" has successfu
lly progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
- lastTransitionTime: "2024-08-11T13:53:34Z"
lastUpdateTime: "2024-08-11T13:53:34Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
observedGeneration: 1
readyReplicas: 2
replicas: 2
updatedReplicas: 2
PS C:\Users\booba>
///now make this into new file
>kubectl get deployment <deployment-name> -o yaml > deployment.yaml
PS C:\Users\booba> kubectl.exe -n akilan logs nginx-ingress-controller-9c9b9b7f7-wr5g4
Error from server (BadRequest): container "nginx-ingress-controller" in pod "nginx-ingress-controller-9c9b9b7f7-wr5g4" is waiting to start: trying and
failing to pull image
PS C:\Users\booba> kubectl.exe -n akilan logs nginx-ingress-controller-9c9b9b7f7-wr5g4 -c nginx-ingress-controller
Error from server (BadRequest): container "nginx-ingress-controller" in pod "nginx-ingress-controller-9c9b9b7f7-wr5g4" is waiting to start: trying and
failing to pull image
///////deployment log check
PS C:\Users\booba> kubectl.exe -n akilan describe deployment nginx-ingress-controller
Name: nginx-ingress-controller
Namespace: akilan
CreationTimestamp: Sun, 11 Aug 2024 21:35:11 +0530
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=nginx-ingress
Replicas: 1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx-ingress
Annotations: kubectl.kubernetes.io/restartedAt: 2024-08-11T16:26:52Z
Containers:
nginx-ingress-controller:
Image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.34.1
Ports: 80/TCP, 443/TCP
Host Ports: 0/TCP, 0/TCP
Args:
/nginx-ingress-controller
--configmap=$(POD_NAMESPACE)/nginx-configuration
Environment:
POD_NAME: (v1:metadata.name)
POD_NAMESPACE: (v1:metadata.namespace)
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available False MinimumReplicasUnavailable
Progressing False ProgressDeadlineExceeded
OldReplicaSets: <none>
NewReplicaSet: nginx-ingress-controller-9c9b9b7f7 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 28m deployment-controller Scaled up replica set nginx-ingress-controller-9c9b9b7f7 to 1
PS C:\Users\booba>
/////login to the pod
PS C:\Users\booba> kubectl.exe -n akilan exec my-microservice-769b859845-dqm7b -it /bin/bash
root@my-microservice-769b859845-dqm7b:/# whoami
root
root@my-microservice-769b859845-dqm7b:/# cat /etc/issue
Debian GNU/Linux 12 \n \l
0 Comments