I. If you are using GKE ingress controller
1)
kubectl run web --image=gcr.io/google-samples/hello-app:1.0 --port=8080
2)
kubectl expose deployment web --target-port=8080 --type=NodePort
3)
cat <<EOF > ./ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx
spec:
backend:
serviceName: web
servicePort: 8080
EOF
4)
kubectl apply -f ingress.yaml
5) Wait up to 5 minutes until GKE apllies firewall rules for your ingress
6) Curl your web app
curl $(kubectl get ingress nginx | awk 'NR==2{print $3}')
II. If you want to do it with nginx ingress controller
1)
kubectl run web --image=gcr.io/google-samples/hello-app:1.0 --port=8080
2)
kubectl expose deployment web --target-port=8080 --type=NodePort
3)
helm install stable/nginx-ingress
4)
cat <<EOF > ./ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: nginx-ingress
spec:
backend:
serviceName: web
servicePort: 8080
EOF
5)
kubectl apply -f ingress.yaml
6)
curl $(kubectl get svc |grep nginx-ingress-controller|awk '{print $4}')