|
~ # kubectl create deployment nginx –image=nginx |
|
deployment.apps/nginx created |
|
~ # kubectl get pods |
|
NAME READY STATUS RESTARTS AGE |
|
nginx-6799fc88d8-wt9qr 1/1 Running 0 53m |
|
~ # POD=$(kubectl get pods -l app=nginx -ojsonpath="{.items[0].metadata.name}") |
|
~ # PID="$(kubectl port-forward $POD 8080:80 >/dev/null 2>&1 & echo $!)" |
|
~ # curl http://localhost:8080/ |
|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<title>Welcome to nginx!</title> |
|
<style> |
|
body { |
|
width: 35em; |
|
margin: 0 auto; |
|
font-family: Tahoma, Verdana, Arial, sans-serif; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<h1>Welcome to nginx!</h1> |
|
<p>If you see this page, the nginx web server is successfully installed and |
|
working. Further configuration is required.</p> |
|
|
|
<p>For online documentation and support please refer to |
|
<a href="http://nginx.org/">nginx.org</a>.<br/> |
|
Commercial support is available at |
|
<a href="http://nginx.com/">nginx.com</a>.</p> |
|
|
|
<p><em>Thank you for using nginx.</em></p> |
|
</body> |
|
</html> |
|
~ # kill "$PID" |
|
~ # kubectl logs $POD |
|
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration |
|
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ |
|
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh |
|
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf |
|
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf |
|
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh |
|
/docker-entrypoint.sh: Configuration complete; ready for start up |
|
127.0.0.1 – – [26/Dec/2020:05:36:22 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.73.0" "-" |
|
~ # kubectl expose deployment nginx –port 80 –type NodePort |
|
service/nginx exposed |
|
~ # kubectl get svc |
|
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
|
kubernetes ClusterIP 10.2.0.1 <none> 443/TCP 4h14m |
|
nginx NodePort 10.2.37.161 <none> 80:30234/TCP 11s |
|
~ # CLUSTERIP="$(kubectl get svc nginx -ojsonpath='{.spec.clusterIP}')" |
|
~ # curl -I http://${CLUSTERIP}/ |
|
HTTP/1.1 200 OK |
|
Server: nginx/1.19.6 |
|
Date: Sat, 26 Dec 2020 07:20:34 GMT |
|
Content-Type: text/html |
|
Content-Length: 612 |
|
Last-Modified: Tue, 15 Dec 2020 13:59:38 GMT |
|
Connection: keep-alive |
|
ETag: "5fd8c14a-264" |
|
Accept-Ranges: bytes |
|
|
|
~ # kubectl delete svc nginx |
|
service "nginx" deleted |
|
~ # kubectl expose deployment nginx –port 8080 –target-port 80 –type LoadBalancer |
|
service/nginx exposed |
|
~ # kubectl get svc |
|
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
|
kubernetes ClusterIP 10.2.0.1 <none> 443/TCP 6h26m |
|
nginx LoadBalancer 10.2.196.18 10.0.10.21 8080:32282/TCP 11s |
|
~ # LBIP="$(kubectl get svc nginx -ojsonpath='{.status.loadBalancer.ingress[0].ip}')" |
|
~ # curl -I http://${LBIP}:8080/ |
|
HTTP/1.1 200 OK |
|
Server: nginx/1.19.6 |
|
Date: Sat, 26 Dec 2020 07:51:23 GMT |
|
Content-Type: text/html |
|
Content-Length: 612 |
|
Last-Modified: Tue, 15 Dec 2020 13:59:38 GMT |
|
Connection: keep-alive |
|
ETag: "5fd8c14a-264" |
|
Accept-Ranges: bytes |
|
|
|
~ # PODIP="$(kubectl get pod "$POD" -ojsonpath='{.status.podIP}')" |
|
~ # kubectl run -it busybox –image busybox –rm=true –restart=Never — wget -q -S -O /dev/null http://${PODIP}/ |
|
HTTP/1.1 200 OK |
|
Server: nginx/1.19.6 |
|
Date: Sat, 26 Dec 2020 08:20:54 GMT |
|
Content-Type: text/html |
|
Content-Length: 612 |
|
Last-Modified: Tue, 15 Dec 2020 13:59:38 GMT |
|
Connection: close |
|
ETag: "5fd8c14a-264" |
|
Accept-Ranges: bytes |
|
|
|
pod "busybox" deleted |
|
~ # |
Leave a Reply