我正在运行一个由三个节点组成的kubernetes集群,并且运行出色,但是现在是使我的Web应用程序安全的时候了,所以我部署了一个入口控制器(traefik)。但是我找不到在其上设置https的说明。我知道我将要做的大多数事情,例如设置“秘密”(带有证书的容器)等,但是我想知道如何配置我的入口控制器和与其相关的所有文件,以便能够使用安全连接
我已经配置了入口控制器并创建了一些前端和后端。我还配置了nginx服务器(实际上是我正在运行的Web应用程序)以在443端口上工作
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: nginx
replicas: 3 # tells deployment to run 3 pods matching the template
template: # create pods using pod definition in this template
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: ilchub/my-nginx
ports:
- containerPort: 443
tolerations:
- key: "primary"
operator: Equal
value: "true"
effect: "NoSchedule"
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: traefik-ingress
namespace: kube-system
labels:
k8s-app: traefik-ingress-lb
spec:
replicas: 1
selector:
matchLabels:
k8s-app: traefik-ingress-lb
template:
metadata:
labels:
k8s-app: traefik-ingress-lb
name: traefik-ingress-lb
spec:
serviceAccountName: traefik-ingress
terminationGracePeriodSeconds: 60
containers:
- image: traefik
name: traefik-ingress-lb
ports:
- name: http
containerPort: 80
- name: https
containerPort: secure
- name: admin
containerPort: 8080
args:
- --api
- --kubernetes
- --logLevel=INFO
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: traefik-web-ui
namespace: kube-system
spec:
rules:
- host: cluster.aws.ctrlok.dev
http:
paths:
- path: /
backend:
serviceName: traefik-web-ui
servicePort: web
kind: Service
apiVersion: v1
metadata:
name: traefik-ingress-service
namespace: kube-system
spec:
selector:
k8s-app: traefik-ingress-lb
ports:
- protocol: TCP
port: 80
nodePort: 30036
name: web
- protocol: TCP
port: 443
nodePort: 30035
name: secure
- protocol: TCP
port: 8080
nodePort: 30034
name: admin
type: NodePort
我要做的是保护已经运行的应用程序。最终结果必须是在https上运行的网页
答案 0 :(得分:0)
实际上,您可以通过3种方式将Traefik配置为使用https与后端Pod通信:
如果存在任何一个配置选项,则假定后端通信协议为TLS,并将自动通过TLS连接。
还应将其他身份验证annotations添加到Ingress对象,例如:
ingress.kubernetes.io/auth-tls-secret: secret