[3.3]
## create NodePort type service [nginx-svc]
vim nginx-expose.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-svc
spec:
type: NodePort
selector:
app: nginx
ports:
- protocol: TCP
port: 8080
targetPort: 80
nodePort: 30144
kubectl apply -f nginx-expose.yaml
kubectl get service
ecs-k8s: curl cce01-node1-IP:30144
[3.3b]
## client access NodePort type service
vim client.yaml
apiVersion: v1
kind: Pod
metadata:
name: clientpod
spec:
containers:
- name: clientpod
image: busybox:1.28.3
args:
- /bin/sh
- -c
- sleep 30000
kubectl apply -f client.yaml
kubectl exec -it clientpod /bin/sh
nslookup <nginx-svc cluster IP>
wget nginx-svc:8080
rm index.html
exit