Hello World

Start Minikube
# ingress on minikube on Docker Desktop does not work
# may due to that it is a container running on Docker Desktop
minikube start --kubernetes-version=v1.22.1 --driver=hyperkit --container-runtime=docker
        
Enable Ingress
minikube addons enable ingress
        
Deploy App
# create deployment
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0

# create service
kubectl expose deployment web --type=NodePort --port=8080

# access app
minikube service web

kubectl port-forward svc/web 8080:8080
http://127.0.0.1:8080/
        
Create Ingress
# ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-ingress # ingress name
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: hello-world.info
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web # service name
                port:
                  number: 8080 # service port
        
kubectl apply -f ingress.yaml
        
Connect Ingress IP and Domain
# get ip of web-ingress
kubectl get ingress

# add ip and domain to /etc/hosts
...
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
192.168.64.5    hello-world.info
...
        
Access App
http://hello-world.info/
        
Reference
  • Documentation