Ingress Addon 설치
vi ~/kubespray/inventory/mycluster/group_vars/k8s_cluster/addons.yml
...
metrics_server_enabled: true
...
...
ingress_nginx_enabled: true
...
ansible-playbook -i inventory/mycluster/inventory.ini cluster.yaml -b
Ingress 설치 확인
kubectl get ns
kubectl get all -n ingress-nginx
kubectl get all po -n kube-system
Yaml 파일
apiVersion: v1
kind: Service
metadata:
name: myweb-svc-np
spec:
type: NodePort
selector:
app: web
ports:
- port: 80
targetPort: 8080
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myweb-rs
spec:
replicas: 3
selector:
matchLabels:
app: web
env: dev
template:
metadata:
labels:
app: web
env: dev
spec:
containers:
- name: myweb
image: ghcr.io/c1t1d0s7/go-myweb
ports:
- containerPort: 8080
protocol: TCP
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myweb-ing
spec:
rules:
- host: '*.encore.xyz'
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myweb-svc-np
port:
number: 80
서비스 삭제
kubectl delete pods [pod이름]
kubectl delete service [service이름]
kubectl delete rs [rs이름]
서비스 실행
kubectl create -f .
없는 도메인 으로 테스트해보기
curl --resolve www.encore.xyz:80:192.168.100.100 http://www.encore.xyz
curl --resolve www.encore.xyz:80:192.168.100.100 http://www.encore.xyz -v
서비스 종료
kubectl delete -f .