【发布时间】:2017-12-02 09:23:43
【问题描述】:
作为一项实验,我尝试使用 Azure 容器服务和 Kubernetes 作为编排器在 Azure 上运行 docker 容器。我正在运行官方的 nginx 映像。以下是我正在采取的步骤:
az group create --name test-group --location westus
az acs create --orchestrator-type=kubernetes --resource-group=test-group --name=k8s-cluster --generate-ssh-keys
我使用 Kompose 从 docker compose 文件创建了 Kubernetes 部署和服务文件。
部署文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.service.type: LoadBalancer
creationTimestamp: null
labels:
io.kompose.service: test
name: test
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: test
spec:
containers:
- image: nginx:latest
name: test
ports:
- containerPort: 80
resources: {}
restartPolicy: Always
status: {}
服务文件
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.service.type: LoadBalancer
creationTimestamp: null
labels:
io.kompose.service: test
name: test
spec:
ports:
- name: "80"
port: 80
targetPort: 80
selector:
io.kompose.service: test
type: LoadBalancer
status:
loadBalancer: {}
然后我可以开始一切:
kubectl create -f test-service.yaml,test-deployment.yaml
一旦一个 IP 被暴露,我就会为其分配一个 dns 前缀,这样我就可以像这样访问我正在运行的容器:http://nginx-test.westus.cloudapp.azure.com/。
我的问题是,如何使用 https 访问该服务?在 https://nginx-test.westus.cloudapp.azure.com/
我认为我不应该为 https 配置 nginx,因为证书不是我的。我尝试更改负载均衡器以将 443 流量发送到端口 80,但收到超时错误。
我尝试在我的 Kubernetes 服务配置中将端口 443 映射到端口 80。
ports:
- name: "443"
port: 443
targetPort: 80
但这会导致:
SSL peer was not expecting a handshake message it received. Error code: SSL_ERROR_HANDSHAKE_UNEXPECTED_ALERT
如何在https://nginx-test.westus.cloudapp.azure.com/查看我正在运行的容器?
【问题讨论】:
-
好吧,你的 nginx 应该服务于 https,而不是 http
-
那我需要绑定证书吗?
-
显然你做到了
-
证书属于微软。所以你是说我不能做我想做的事?
-
哪个证书,我不明白?为什么你的 nginx 上的证书会属于 ms?
标签: azure docker https kubernetes