Code Monkey home page Code Monkey logo

k8s102's Introduction

lesson 1.3.2-run-nginx-with-k8s

  1. Run command to enter lesson $ cd chapter01-basic-knowledges/1.3-basic-kubernetes/02-run-nginx-with-k8s

  2. Run command to create namespace $ kubectl apply -f 00-namespace.yml namespace/basic-k8s created

  3. 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

  4. Create deployment for nginx $ kubectl apply -f 01-deployment.yml deployment.apps/nginx created

  5. Check for nginx deployment $ kubectl get pod -n basic-k8s NAME READY STATUS RESTARTS AGE nginx-86469cbbfd-89cd6 1/1 Running 0 46s

  6. Create service for nginx $ kubectl apply -f 02-service.yml service/nginx created

  7. 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

  8. Create ingress rule to nginx service $ kubectl apply -f 03-ingress.yml ingress.extensions/ingress created

  9. 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

  10. Test access service via ingress $ curl -X GET "http://kubernetes.docker.internal"

<title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style>

Welcome to nginx!

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.

  1. Run command to cleanup $ kubectl delete ns basic-k8s

  2. 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

k8s102's People

Contributors

paretkf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.