kubectl create deploy --image=gasbugs/http-go http-go --port=8080 --dry-run=client -o yaml
kubectl create deploy --image=gasbugs/http-go http-go --port=8080 --dry-run=client -o yaml > http-go-deploy.yaml
http-go-deploy.yaml
apiVersion: v1
kind: Service
metadata:
name: http-go-svc
spec:
selector:
run: http-go
ports:
- protocol: TCP
port: 80
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: http-go
name: http-go
spec:
replicas: 1
selector:
matchLabels:
run: http-go
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
run: http-go
spec:
containers:
- image: gasbugs/http-go
name: http-go
ports:
- containerPort: 8080
resources: {}
status: {}
nano http-go-deploy.yaml
kubectl create -f http-go-deploy.yaml
kubectl get all
kubectl get pods -o wide
kubectl describe svc
inkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl describe svc
Name: http-go-svc
Namespace: default
Labels: <none>
Annotations: cloud.google.com/neg: {"ingress":true}
Selector: run=http-go
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.108.3.150
IPs: 10.108.3.150
Port: <unset> 80/TCP
TargetPort: 8080/TCP
>> Endpoints: 10.104.2.5:8080
Session Affinity: None
Events: <none>
kubectl scale deploy http-go --replicas=5
kubectl get pod -w
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
http-go-85cf4fd86b-7wcn8 1/1 Running 0 76s 10.104.2.6 gke-my-first-cluster-1-default-pool-a0f2cf43-zs3g <none> <none>
http-go-85cf4fd86b-8qh56 1/1 Running 0 3m35s 10.104.2.5 gke-my-first-cluster-1-default-pool-a0f2cf43-zs3g <none> <none>
http-go-85cf4fd86b-ktv6b 1/1 Running 0 76s 10.104.0.8 gke-my-first-cluster-1-default-pool-a0f2cf43-m3k4 <none> <none>
http-go-85cf4fd86b-s2t45 1/1 Running 0 76s 10.104.1.5 gke-my-first-cluster-1-default-pool-a0f2cf43-20cx <none> <none>
http-go-85cf4fd86b-wx5sv 1/1 Running 0 76s 10.104.1.4 gke-my-first-cluster-1-default-pool-a0f2cf43-20cx <none> <none>
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl describe svc http-go-svc
Name: http-go-svc
Namespace: default
Labels: <none>
Annotations: cloud.google.com/neg: {"ingress":true}
Selector: run=http-go
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.108.3.150
IPs: 10.108.3.150
Port: <unset> 80/TCP
TargetPort: 8080/TCP
Endpoints: 10.104.0.8:8080,10.104.1.4:8080,10.104.1.5:8080 + 2 more...
Session Affinity: None
Events: <none>
kubectl edit svc http-go-svc
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl get svc http-go-svc -o yaml
apiVersion: v1
kind: Service
metadata:
annotations:
cloud.google.com/neg: '{"ingress":true}'
creationTimestamp: "2023-07-25T18:35:03Z"
name: http-go-svc
namespace: default
resourceVersion: "2967358"
uid: c478a5aa-9165-4f71-94eb-c8542dd57793
spec:
clusterIP: 10.108.3.150
clusterIPs:
- 10.108.3.150
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
run: http-go
>> sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: 10800
type: ClusterIP
status:
loadBalancer: {}
kubectl run -it --rm --image=busybox bash
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl run -it --rm --image=busybox bash
If you don't see a command prompt, try pressing enter.
/ #
/ #
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
/ # wget -O- -q 10.108.3.150
Welcome! http-go-85cf4fd86b-7wcn8
-- 같은 ip로 유지 (ClientIP)
Reference: