my-service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app.kubernetes.io/name: MyApp # 선택할 label
ports:
- protocol: TCP
port: 80 # Cluster-Ip 포트
targetPort: 9376 # 포드의 포트
kubectl create -f my-service.yaml
kubectl get svc
kubectl expose..
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
sessionAffinity: ClientIP
selector:
app.kubernetes.io/name: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
sessionAffinity: ClientIP
selector:
app: myApp
ports:
- name: http
port: 80
targetPort: 8080
- name: https
port: 443
targetPort: 8443
imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.44.0.1 <none> 443/TCP 3d7h
my-service ClusterIP 10.44.6.22 <none> 80/TCP,443/TCP 5s
imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl describe svc my-service
Name: my-service
Namespace: default
Labels: <none>
Annotations: cloud.google.com/neg: {"ingress":true}
Selector: app=myApp
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.44.14.7
IPs: 10.44.14.7
Port: http 80/TCP
TargetPort: 8080/TCP
Endpoints: 10.40.0.20:8080
Port: https 443/TCP
TargetPort: 8443/TCP
Endpoints: 10.40.0.20:8443
Session Affinity: ClientIP
Events: <none>
imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
admin-page 1/1 Running 0 3d5h 10.40.0.5 gke-artbridge-default-pool-65403ed8-7zvx <none> <none>
front-end 1/1 Running 0 3d5h 10.40.1.5 gke-artbridge-default-pool-65403ed8-fz5f <none> <none>
jenkins-deployment-58f88d9746-gmvkc 1/1 Running 0 2d10h 10.40.0.6 gke-artbridge-default-pool-65403ed8-7zvx <none> <none>
jhipster-prometheus-operator-77c8f847cb-sr7sx 1/1 Running 0 45h 10.40.0.14 gke-artbridge-default-pool-65403ed8-7zvx <none> <none>
mariadb-5bfcbc8dd5-vm69q 1/1 Running 0 8h 10.40.1.15 gke-artbridge-default-pool-65403ed8-fz5f <none> <none>
nginx 1/1 Running 0 90s 10.40.0.20 gke-artbridge-default-pool-65403ed8-7zvx <none> <none>
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app.kubernetes.io/name: MyApp
ports:
- name: http
protocol: TCP
port: 80
targetPort: 49152
externalIPs:
- 198.51.100.32