$ helm search nginx-ingress
NAME VERSION DESCRIPTION
local/nginx-ingress 0.8.9 An nginx Ingress controller that uses ConfigMap...
stable/nginx-ingress 0.8.9 An nginx Ingress controller that uses ConfigMap...
stable/nginx-lego 0.3.0 Chart for nginx-ingress-controller and kube-lego
使用helm部署nginx-ingress
$ helm install --name nginx-ingress local/nginx-ingress
NAME: nginx-ingress
LAST DEPLOYED: Fri Oct 27 18:26:58 2017
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> rbac.authorization.k8s.io/v1beta1/Role
NAME KIND
nginx-ingress-nginx-ingress Role.v1beta1.rbac.authorization.k8s.io
==> rbac.authorization.k8s.io/v1beta1/RoleBinding
nginx-ingress-nginx-ingress RoleBinding.v1beta1.rbac.authorization.k8s.io
==> v1/Service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-ingress-nginx-ingress-controller 10.254.100.108 <nodes> 80:30484/TCP,443:31053/TCP 1s
nginx-ingress-nginx-ingress-default-backend 10.254.58.156 <none> 80/TCP 1s
==> extensions/v1beta1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-ingress-nginx-ingress-default-backend 1 1 1 0 1s
nginx-ingress-nginx-ingress-controller 1 1 1 0 1s
==> v1/ConfigMap
NAME DATA AGE
nginx-ingress-nginx-ingress-controller 1 1s
==> v1/ServiceAccount
NAME SECRETS AGE
nginx-ingress-nginx-ingress 1 1s
==> rbac.authorization.k8s.io/v1beta1/ClusterRole
NAME KIND
nginx-ingress-nginx-ingress ClusterRole.v1beta1.rbac.authorization.k8s.io
==> rbac.authorization.k8s.io/v1beta1/ClusterRoleBinding
nginx-ingress-nginx-ingress ClusterRoleBinding.v1beta1.rbac.authorization.k8s.io
NOTES:
The nginx-ingress controller has been installed.
Get the application URL by running these commands:
export HTTP_NODE_PORT=$(kubectl --namespace default get services -o jsonpath="{.spec.ports[0].nodePort}" nginx-ingress-nginx-ingress-controller)
export HTTPS_NODE_PORT=$(kubectl --namespace default get services -o jsonpath="{.spec.ports[1].nodePort}" nginx-ingress-nginx-ingress-controller)
export NODE_IP=$(kubectl --namespace default get nodes -o jsonpath="{.items[0].status.addresses[1].address}")
echo "Visit http://$NODE_IP:$HTTP_NODE_PORT to access your application via HTTP."
echo "Visit https://$NODE_IP:$HTTPS_NODE_PORT to access your application via HTTPS."
An example Ingress that makes use of the controller:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: example
namespace: foo
spec:
rules:
- host: www.example.com
http:
paths:
- backend:
serviceName: exampleService
servicePort: 80
path: /
# This section is only required if TLS is to be enabled for the Ingress
tls:
- hosts:
- www.example.com
secretName: example-tls
If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:
apiVersion: v1
kind: Secret
metadata:
name: example-tls
namespace: foo
data:
tls.crt: <base64 encoded cert>
tls.key: <base64 encoded key>
type: kubernetes.io/tls
export HTTP_NODE_PORT=$(kubectl --namespace default get services -o jsonpath="{.spec.ports[0].nodePort}" nginx-ingress-nginx-ingress-controller)
export HTTPS_NODE_PORT=$(kubectl --namespace default get services -o jsonpath="{.spec.ports[1].nodePort}" nginx-ingress-nginx-ingress-controller)
export NODE_IP=$(kubectl --namespace default get nodes -o jsonpath="{.items[0].status.addresses[1].address}")
echo "Visit http://$NODE_IP:$HTTP_NODE_PORT to access your application via HTTP."
echo "Visit https://$NODE_IP:$HTTPS_NODE_PORT to access your application via HTTPS."
Visit http://172.20.0.113:30484 to access your application via HTTP.
Visit https://172.20.0.113:31053 to access your application via HTTPS.