Minikube-Kubernetes本地环境进行开发
程序员文章站
2022-10-24 16:45:01
Minikube Kubernetes本地环境进行开发 使用Minikube 启动Minikube 获取命名空间 获取集群信息 获取节点信息 运行nginx 获取pods 查看Pod日志 进入Pod中 获取deployment 获取svc(services) 使用Minikube获取服务访问地址 删 ......
minikube-kubernetes本地环境进行开发
使用minikube
启动minikube
# 启动 minkube start # 检查状态 minikube status host: running kubelet: running apiserver: running kubectl: correctly configured: pointing to minikube-vm at 192.168.99.100 # 访问面板 $ minikube dashboard # 访问web前端 $ kubectl proxy
获取命名空间
# kubectl get namespaces $ kubectl get ns name status age default active 156m kube-node-lease active 156m kube-public active 156m kube-system active 156m
获取集群信息
$ kubectl cluster-info kubernetes master is running at https://192.168.99.100:8443 kubedns is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube- dns:dns/proxy to further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
获取节点信息
$ kubectl get node name status roles age version minikube ready master 162m v1.14.1
运行nginx
# 运行nginx $ kubectl run nginx --image=nginx:1.16 --port=80 --labels="app=nginx,env=dev" # 增加新标签 # kubectl label pod $pod_name app2=test # 发布服务采用对外暴露节点 $ kubectl expose deployment nginx --type=nodeport
获取pods
$ kubectl get pods # 根据标签查询 # kubectl get pods -l app=nginx name ready status restarts age nginx-fcb945956-t8bqq 1/1 running 0 67s # 获取pod详细信息 # kubectl describe pods -l app=nginx
查看pod日志
kubectl logs $pod_name
进入pod中
# 查看环境 # kubectl exec $pod_name env $ kubectl exec -ti nginx-fcb945956-t8bqq /bin/bash
获取deployment
$ kubectl get deployment name ready up-to-date available age nginx 1/1 1 1 18m # 获取描述 $ kubectl describe deployment name: nginx namespace: default creationtimestamp: wed, 15 may 2019 23:29:23 +0800 labels: app=nginx env=dev annotations: deployment.kubernetes.io/revision: 1 selector: app=nginx,env=dev replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable strategytype: rollingupdate minreadyseconds: 0 rollingupdatestrategy: 25% max unavailable, 25% max surge pod template: labels: app=nginx env=dev containers: nginx: image: nginx:1.16 port: 8081/tcp host port: 0/tcp environment: <none> mounts: <none> volumes: <none> conditions: type status reason ---- ------ ------ available true minimumreplicasavailable progressing true newreplicasetavailable oldreplicasets: <none> newreplicaset: nginx-fcb945956 (1/1 replicas created) events: type reason age from message ---- ------ ---- ---- ------- normal scalingreplicaset 18m deployment-controller scaled up replica set nginx-fcb945956 to 1
获取svc(services)
# kubectl get svc $ kubectl get services name type cluster-ip external-ip port(s) age kubernetes clusterip 10.96.0.1 <none> 443/tcp 3h8m nginx nodeport 10.105.192.17 <none> 80:31199/tcp 5m9s # 获取详情 $ kubectl describe services name: kubernetes namespace: default labels: component=apiserver provider=kubernetes annotations: <none> selector: <none> type: clusterip ip: 10.96.0.1 port: https 443/tcp targetport: 8443/tcp endpoints: 192.168.99.100:8443 session affinity: none events: <none> name: nginx namespace: default labels: app=nginx env=dev annotations: <none> selector: app=nginx,env=dev type: nodeport ip: 10.105.192.17 port: <unset> 80/tcp targetport: 80/tcp nodeport: <unset> 31199/tcp endpoints: 172.17.0.5:80 session affinity: none external traffic policy: cluster events: <none>
使用minikube获取服务访问地址
# 获取服务url $ minikube service nginx --url # 访问测试 $ curl $(minikube service nginx --url)
删除服务
# kubectl delete deployments --all $ kubectl delete deployments -l app=nginx # kubectl delete pods --all $ kubectl delete pods -l app=nginx # 删除service kubectl delete service -l app=nginx
停止minikube
minikube stop
参考
上一篇: linux系统中rsync+inotify实现服务器之间文件实时同步
下一篇: 一个人的经历
推荐阅读
-
spring cloud 阿波罗 apollo 本地开发环境搭建过程
-
webpack本地开发环境无法用IP访问的解决方法
-
spark-windows(含eclipse配置)下本地开发环境搭建
-
如何进行微信公众号开发的本地调试的方法
-
PHP+Oracle本地开发环境搭建方法详解
-
Google Earth Engine——windowns下搭建GEE本地python开发环境
-
用WebStorm进行Angularjs 2开发(环境篇:Windows 10,Angular-cli方式)
-
webpack本地开发环境无法用IP访问的解决方法
-
新版vue-cli模板下本地开发环境使用node服务器跨域的方法
-
Minikube-Kubernetes本地环境进行开发