环境配置
连接cluster
1 | gcloud container clusters get-credentials CLUSER_NAME --zone us-central1-a --project PROJECT_NAME |
安装helm和tiller
1 | kubectl create serviceaccount --namespace kube-system tiller |
安装nginx-ingress
1 | helm install --name nginx-ingress stable/nginx-ingress --set rbac.create=true --set controller.publishService.enabled=true |
安装let’s encrypt
1 | kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.8/deploy/manifests/00-crds.yaml |
1 | apiVersion: certmanager.k8s.io/v1alpha1 |
配置DNS
获取nginx-ingress-controller的IP
1 | kubectl get svc -n default |
output:
1 | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
将你的DNS记录指向 EXTERNAL-IP -> 35.188.93.188
部署web项目
创建namespace
1 | kubectl create ns demo |
部署项目
Deployment
1 | kubectl apply -f deployment.yaml |
1 | apiVersion: apps/v1 |
Service
1 | kubectl apply -f service.yaml |
1 | apiVersion: v1 |
Ingress
1 | kubectl apply -f ingress.yaml |
1 | apiVersion: extensions/v1beta1 |
等deployment
的pod ready
后,访问你配置的域名,就可以看到https加密后的tomcat主页了。
Links
- https://cloud.google.com/community/tutorials/nginx-ingress-gke
- https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-on-digitalocean-kubernetes-using-helm
- https://gist.github.com/snormore/c7c2935d746531ed0d75064a6ad6058e
- https://github.com/helm/helm/issues/3130#issuecomment-372931407
- kubernetes-sample-app
Update
- 2019-09-08: 添加了let’s encrypt部分缺失的安装步骤。