Kubernetes Ingress HTTPS

Arif KIZILTEPE
2 min readOct 6, 2022

--

Kubernetes ingress ile erişime açtığımız uygulamalara güvenli erişim ihtiyacımız zaman zamna oluyor. Bu durum için farklı bir katman daha koyarak ssl-offloading işlemini apache/nginx/haproxy gibi ürünler ile de yapabilirsiniz ama bu işin daha kolayı var, ingress modulleri ssl sertifikasını eklemeyi destekliyor. Bu işlem için sertifikalarımızı master sunucuya kopyalıyoruz. Aşağıdaki komutu çalıştırırken sertifikaların o dizinde olduğuna emin olun.

Not: Kullandığım valid sertifikanın kök sertifika bilgileri bazı ortamlarda olmadığı için doğruluk konusunda sorun yaşıyorum. Bu durumdan kurtulmak için bundle kullanıyorum.

kubectl create secret tls xxx.com  --key star.xxx.com.key --cert star.xxx.com.ca-bundle

Daha sonra ingress içerisine aşağıdaki tanımları ekliyoruz.

tls:
- hosts:
- hellonode.xxx.com
secretName: xxx.com

Örnek bir ingress şu şekilde oluyor.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hellonode
namespace: default
spec:
ingressClassName: kong
tls:
- hosts:
- hellonode.xxx.paytr.com
secretName: xxx.com
rules:
- host: hellonode.xxx.com
http:
paths:
- path: /api-testpipeline
pathType: Prefix
backend:
service:
name: hellonode
port:
number: 80

Full manifest dosyam da böyle;

apiVersion: apps/v1
kind: Deployment
metadata:
name: hellonode
namespace: default
labels:
app: hellonode
spec:
replicas: 2
revisionHistoryLimit: 3
selector:
matchLabels:
app: hellonode
template:
metadata:
labels:
app: hellonode
spec:
containers:
- name: hellonode
image: nexus.xxx.com:8083/hellonode:3.3
imagePullPolicy: Always
resources:
limits:
memory: 6144Mi
requests:
memory: 2048Mi
ports:
- containerPort: 80
imagePullSecrets:
- name: paytrnexus
---
apiVersion: v1
kind: Service
metadata:
name: hellonode
namespace: default
labels:
app: hellonode
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
targetPort: 443
protocol: TCP
name: https
selector:
app: hellonode
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hellonode
namespace: default
spec:
ingressClassName: kong
tls:
- hosts:
- hellonode.xxx.com
secretName: xxx.com
rules:
- host: hellonode.xxx.com
http:
paths:
- path: /api-testpipeline
pathType: Prefix
backend:
service:
name: hellonode
port:
number: 80

İşlemleri kubernetes ortama deploy ettikten sonra kontrol edebiliriz.

--

--

No responses yet