1. Kubernetes create deployment and pod
> kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready master 62m v1.16.6-beta.0
> kubectl run testnginx --image lqwangxg/nginx
kubectl run --generator=deployment/apps.v1 is DEPRECATED and
will be removed in a future version.
Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/testnginx created
> kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
testnginx 1/1 1 1 62s
> kubectl get pods
NAME READY STATUS RESTARTS AGE
testnginx-78cc8cbd6c-7x4zb 1/1 Running 0 98s
> kubectl get nodes NAME STATUS ROLES AGE VERSION docker-desktop Ready master 62m v1.16.6-beta.0 > kubectl run testnginx --image lqwangxg/nginx kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead. deployment.apps/testnginx created > kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE testnginx 1/1 1 1 62s > kubectl get pods NAME READY STATUS RESTARTS AGE testnginx-78cc8cbd6c-7x4zb 1/1 Running 0 98s
2. Kubernetes expose deployment as service
> kubectl expose deployment testnginx --port 80 --type NodePort
service/testnginx exposed
> kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 74m
testnginx NodePort 10.106.146.174 <none> 80:32171/TCP 28s
> curl http://localhost
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...
> curl http://localhost:32171
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<...
> kubectl delete deployment testnginx
deployment.apps "testnginx" deleted
> kubectdl delete service
service "testnginx" deleted
> kubectl expose deployment testnginx --port 80 --type NodePort service/testnginx exposed > kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 74m testnginx NodePort 10.106.146.174 <none> 80:32171/TCP 28s
> curl http://localhost StatusCode : 200 StatusDescription : OK Content : <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> ... > curl http://localhost:32171 StatusCode : 200 StatusDescription : OK Content : <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> <...
> kubectl delete deployment testnginx deployment.apps "testnginx" deleted > kubectdl delete service service "testnginx" deleted
没有评论:
发表评论