它将创建一个kubeconfig文件并且保存在你运行命令的目录中 。
步骤4:导出KUBECONFIG
[root@ip-172-31-33-136 bin]#** export KUBECONFIG=`pwd`/kubeconfig**步骤5:开始玩转k3s
[root@ip-172-31-33-136 bin]# **./kubectl get nodes**NAME STATUS ROLES AGE VERSIONip-172-31-33-136.ec2.internal Ready master 24s v1.14.5-k3s.1[root@ip-172-31-33-136 bin]# **./kubectl get pods -n kube-system**NAME READY STATUS RESTARTS AGEcoreDNS-b7464766c-ngf46 1/1 Running 0 4m3shelm-install-traefik-x6wfj 0/1 Completed 0 4m3ssvclb-traefik-65Gw9 2/2 Running 0 3m49straefik-56688c4464-5rdss 1/1 Running 0 3m49s运行一个简单的服务:
# Create a Deployment**./kubectl run Nginx --image=nginx**# Create Service[root@ip-172-31-33-136 bin]# **./kubectl expose deployment nginx --port=80 --target-port=80**service/nginx exposed[root@ip-172-31-33-136 bin]# **./kubectl get svc**NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEkubernetes ClusterIP 10.43.0.1 <none> 443/TCP 45mnginx ClusterIP 10.43.99.179 <none> 80/TCP 5s[root@ip-172-31-33-136 bin]# **curl 10.43.99.179**<!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 andworking. Further configuration is required.</p><p>For online documentation and support please refer to<a href=https://www.isolves.com/it/cxkf/bk/2019-08-28/"http://nginx.org/">nginx.org.
Commercial support is available atnginx.com.
Thank you for using nginx.
