Helm安装IngressNginx(作废)

执行指令如下:

1
2
3
4
5

helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace

创建服务进行测试

  1. 创建必要的资源
 1
 2
 3
 4
 5
 6
 7
 8
 9
10

# 创建一个Deployment及Service
kubectl create deployment demo --image=httpd --port=80
kubectl expose deployment demo

# 创建Ingress资源
kubectl create ingress demo-localhost \
  --class=nginx \
  --rule=demo.localdev.me/*=demo:80

  1. 使用kubectl get services -n ingress-nginx -o wide查看Ingress的端口

2022-01-13-15-21-31

  1. 配置开发机的Host

2022-01-13-15-21-09

  1. 使用浏览器进行访问

2022-01-13-15-20-50

检查Ingress Controller Version

1
2
3
4
5

POD_NAMESPACE=ingress-nginx
POD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app.kubernetes.io/name=ingress-nginx --field-selector=status.phase=Running -o name)
kubectl exec $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version

生成证书

1
2
3
4
5
6

openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout nginx.key \
  -out nginx.crt \
  -subj "/CN=th-2"

  • CountryName(/C)

  • StateOrProvinceName(/ST)

  • LocalityName(/L)

  • OrganizationName(/O)

  • OrganizationUnitName(/OU)

  • CommonName(ed,your name or your server’s name)(/CN)

  • EmailAddress(/emailAddress)

参考资料

  1. NGINX Ingress Controller