Ingress
Follow along:
jayadmin@cloudshell:~ (kubetrain-331123)$ helm version
version.BuildInfo{Version:"v3.5.0", GitCommit:"32c22239423b3b4ba6706d450bd044baffdcf9e6", GitTreeState:"clean", GoVersion:"go1.15.6"}
jayadmin@cloudshell:~ (kubetrain-331123)$ helm repo list
Error: no repositories to show
jayadmin@cloudshell:~ (kubetrain-331123)$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
"ingress-nginx" has been added to your repositories
jayadmin@cloudshell:~ (kubetrain-331123)$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "ingress-nginx" chart repository
Update Complete. ⎈Happy Helming!⎈
jayadmin@cloudshell:~ (kubetrain-331123)$ kubectl create ns nginx-ingress
namespace/nginx-ingress created
jayadmin@cloudshell:~ (kubetrain-331123)$ helm install nginx ingress-nginx/ingress-nginx ^Cn nginx-ingress
jayadmin@cloudshell:~ (kubetrain-331123)$ kubectl get ingressclass
No resources found
jayadmin@cloudshell:~ (kubetrain-331123)$ helm install nginx ingress-nginx/ingress-nginx nginx-ingress
Error: expected at most two arguments, unexpected arguments: nginx-ingress
jayadmin@cloudshell:~ (kubetrain-331123)$ helm install nginx ingress-nginx/ingress-nginx -n nginx-ingress
NAME: nginx
LAST DEPLOYED: Sat Jan 22 17:16:20 2022
NAMESPACE: nginx-ingress
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The ingress-nginx controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace nginx-ingress get services -o wide -w nginx-ingress-nginx-controller'
An example Ingress that makes use of the controller:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example
namespace: foo
spec:
ingressClassName: nginx
rules:
- host: www.example.com
http:
paths:
- backend:
service:
name: exampleService
port:
number: 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
jayadmin@cloudshell:~ (kubetrain-331123)$ kubectl get ingressclass
NAME CONTROLLER PARAMETERS AGE
nginx k8s.io/ingress-nginx <none> 33s
jayadmin@cloudshell:~ (kubetrain-331123)$ kubectl get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default client-srv ClusterIP 10.56.5.87 <none> 3000/TCP 23d
default database ClusterIP None <none> <none> 23d
default kubernetes ClusterIP 10.56.0.1 <none> 443/TCP 52d
default mongo-srv ClusterIP 10.56.0.54 <none> 27017/TCP 23d
default react-cat ClusterIP 10.56.13.203 <none> 80/TCP 10d
default react-cat-backend NodePort 10.56.5.150 <none> 3000:31282/TCP 10d
default react-hello ClusterIP 10.56.12.123 <none> 80/TCP 40d
default react-hello-https NodePort 10.56.15.176 <none> 443:32125/TCP 40d
default todo-backend-service ClusterIP 10.56.15.152 <none> 5000/TCP 35d
jagadish myjava-app-service ClusterIP 10.56.7.48 <none> 80/TCP 47d
kube-system default-http-backend NodePort 10.56.14.152 <none> 80:30394/TCP 52d
kube-system kube-dns ClusterIP 10.56.0.10 <none> 53/UDP,53/TCP 52d
kube-system metrics-server ClusterIP 10.56.2.170 <none> 443/TCP 52d
nginx-ingress nginx-ingress-nginx-controller LoadBalancer 10.56.12.48 35.223.53.153 80:32765/TCP,443:31262/TCP 2m36s
nginx-ingress nginx-ingress-nginx-controller-admission ClusterIP 10.56.0.16 <none> 443/TCP 2m36s
jayadmin@cloudshell:~ (kubetrain-331123)$ kubectl get all -n nginx
No resources found in nginx namespace.
jayadmin@cloudshell:~ (kubetrain-331123)$ kubectl get all -n nginx-ingress
NAME READY STATUS RESTARTS AGE
pod/nginx-ingress-nginx-controller-559779bdcc-b8wjs 1/1 Running 0 3m21s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nginx-ingress-nginx-controller LoadBalancer 10.56.12.48 35.223.53.153 80:32765/TCP,443:31262/TCP 3m21s
service/nginx-ingress-nginx-controller-admission ClusterIP 10.56.0.16 <none> 443/TCP 3m21s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx-ingress-nginx-controller 1/1 1 1 3m21s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-ingress-nginx-controller-559779bdcc 1 1 1 3m21s
jayadmin@cloudshell:~/react-hello (kubetrain-331123)$ ping www.codeviewing.com
PING www.codeviewing.com (35.223.53.153) 56(84) bytes of data.
64 bytes from 153.53.223.35.bc.googleusercontent.com (35.223.53.153): icmp_seq=1 ttl=108 time=39.0 ms
64 bytes from 153.53.223.35.bc.googleusercontent.com (35.223.53.153): icmp_seq=2 ttl=108 time=39.3 ms
64 bytes from 153.53.223.35.bc.googleusercontent.com (35.223.53.153): icmp_seq=3 ttl=108 time=39.0 ms
^C
--- www.codeviewing.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 5ms
rtt min/avg/max/mdev = 38.962/39.074/39.279/0.270 ms
jayadmin@cloudshell:~/react-hello (kubetrain-331123)$ curl www.codeviewing.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
....