lesson 1.3.2-run-nginx-with-k8s
-
Run command to enter lesson $ cd chapter01-basic-knowledges/1.3-basic-kubernetes/02-run-nginx-with-k8s
-
Run command to create namespace $ kubectl apply -f 00-namespace.yml namespace/basic-k8s created
-
Check for namespace (basic-k8s) $ kubectl get ns NAME STATUS AGE basic-k8s Active 19s default Active 6h40m kube-node-lease Active 6h40m kube-public Active 6h40m kube-system Active 6h40m
-
Create deployment for nginx $ kubectl apply -f 01-deployment.yml deployment.apps/nginx created
-
Check for nginx deployment $ kubectl get pod -n basic-k8s NAME READY STATUS RESTARTS AGE nginx-86469cbbfd-89cd6 1/1 Running 0 46s
-
Create service for nginx $ kubectl apply -f 02-service.yml service/nginx created
-
Check for service nginx $ kubectl get svc -n basic-k8s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx ClusterIP 10.98.127.130 8080/TCP,8443/TCP 8s
-
Create ingress rule to nginx service $ kubectl apply -f 03-ingress.yml ingress.extensions/ingress created
-
Check for ingress rule (ing = ingress) $ kubectl get ing -n basic-k8s NAME CLASS HOSTS ADDRESS PORTS AGE ingress kubernetes.docker.internal localhost 80 36s
-
Test access service via ingress $ curl -X GET "http://kubernetes.docker.internal"
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
-
Run command to cleanup $ kubectl delete ns basic-k8s
-
Run command to exit directory $ cd ../../../
note
ถ้า curl -X GET "http://kubernetes.docker.internal"
แล้วไม่เจอให้ลองตรวจสอบ host file
$ code /private/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section