- 阿里 dns
223.5.5.5
- kubectl get pods -n kube-system
- 测试 kubernetes 集群
在 Kubernetes 集群中创建一个 pod,验证是否正常运行:
$ kubectl create deployment nginx --image=nginx $ kubectl expose deployment nginx --port=80 --type=NodePort $ kubectl get pod,svc
访问地址:http://NodeIP:Port
- kubectl 工具查看当前集群组件状态
kubectl get cs
- Error from server (Forbidden): Forbidden (user=kubernetes, verb=get, resource=nodes, subresource=proxy) ( pods/log java-k8sdemo-68647fdfd7-pwnnj)
[root@m1 ~]# kubectl create clusterrolebinding kubernetes --clusterrole=cluster-admin --user=kubernetes
- 两种安装方式比较
- yaml 文件中,controller & pod
- 容器交付过程
- 制作镜像
docker build -t xxl-job-executor-sample-springboot:2.2.0 .
- 查看镜像是否制作成功
- 将镜像推送到镜像仓库
$ sudo docker login --username=xil**** registry.cn-shanghai.aliyuncs.com $ sudo docker tag [ImageId] registry.cn-shanghai.aliyuncs.com/java-k8sdemo/xxl-job-executor:[镜像版本号] $ sudo docker push registry.cn-shanghai.aliyuncs.com/java-k8sdemo/xxl-job-executor:[镜像版本号]
- 从阿里云下载镜像部署到本地 k8s:
1. kubectl create deployment xxl-job-admin --image=registry.cn-shanghai.aliyuncs.com/java-k8sdemo/xxl-job-admin:2.2.0 --dry-run -o yaml > xxl-job-admin-deployment.yaml
kubectl create deployment xxl-job-executor --image=registry.cn-shanghai.aliyuncs.com/java-k8sdemo/xxl-job-executor-sample-springboot:2.2.0 --dry-run -o yaml > xxl-job-executor-deployment.yaml
2. kubectl apply -f xxl-job-admin-deployment.yaml
kubectl apply -f xxl-job-executor-deployment.yaml
3. kubectl expose deployment xxl-job-admin --port=8080 --target-port=8080 --type=NodePort --dry-run=client -o yaml > xxl-job-admin-svc-expose.yaml
kubectl expose deployment xxl-job-executor --port=7001 --target-port=7001 --type=NodePort --dry-run=client -o yaml > xxl-job-executor-svc.yaml