반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- keda
- Kubernetes 인증
- knative
- nginx ingress
- argocd
- blue/green
- 카오스 엔지니어링
- seldon core
- Continuous Deployment
- Model Serving
- xdp
- tekton
- mlops
- Kubeflow
- Kopf
- serving
- MLflow
- CI/CD
- CANARY
- eBPF
- opentelemetry
- operator
- Kubernetes
- 오퍼레이터
- Litmus
- Argo
- kubernetes operator
- gitops
- opensearch
- Pulumi
Archives
- Today
- Total
Kubernetes 이야기
nginx ingress를 사용하여 외부 application proxy 설정 본문
반응형
Kubernetes Cluster 에 배포된 application 이 아닌 일반 물리 또는 VM에 application 서비스 ( 예를 들어 Tomcat 서비스 )를 Nginx Ingress로 등록하여 사용하는 방법에 대해 알아보자. 구성은 아래와 같은 그림이 될 것이다.
먼저 Kubernetes Service를 위한 Ingress를 먼저 만들어보자.
apiVersion: apps/v1
kind: Deployment
metadata:
name: sampleapp
spec:
replicas: 1
selector:
matchLabels:
app: sampleapp
template:
metadata:
labels:
app: sampleapp
spec:
containers:
- name: sampleapp
image: nginx
ports:
- containerPort: 80
imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: sampleapp
spec:
type: ClusterIP
selector:
app: sampleapp
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: ingress-tomcat
spec:
rules:
- host: sampleapp.10.60.200.121.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sampleapp
port:
number: 80
브라우저에서 호출해 보면 아래와 같다.
이제 VM 서버에 Tomcat 을 배포하고 호출해보자.
위의 Tomcat을 Kubernetes Cluster에서 호출하기 위해서는 먼저 Service를 만든다.
apiVersion: v1
kind: Service
metadata:
name: tomcat
spec:
type: ExternalName
externalName: tomcat.mydomain.com
ExternalName은 domain으로만 호출할 수 있기 때문에 IP 로 호출해야 하는 경우에는 사용하지 못한다.
그래서 IP 로 등록하는 경우는 아래와 같은 절차로 진행한다.
apiVersion: v1
kind: Service
metadata:
name: external-tomcat
spec:
ports:
- port: 8080
---
apiVersion: v1
kind: Endpoints
metadata:
name: external-tomcat
subsets:
- addresses:
- ip: 10.60.100.41
ports:
- port: 8080
이렇게 생성 후 아래와 같이 Ingress를 생성해 보자.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: ingress-tomcat
spec:
rules:
- host: tomcatapp.10.60.200.121.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: external-tomcat
port:
number: 8080
호출해 보면 아래와 같이 보일 것이다.
반응형
'Kubernetes > 일반' 카테고리의 다른 글
Kubestr로 Storage 구성 및 성능 평가 (0) | 2022.04.22 |
---|---|
OpenEBS (0) | 2022.04.22 |
올바른 Dockerfile 작성하기 (0) | 2022.04.19 |
Nginx ingress - External OAUTH Authentication ( Google ) (0) | 2022.04.17 |
Kubernetes Cluster 설계 (0) | 2022.04.10 |
Comments