1. 配置文件方式部署pod
1.1 生成yaml文件
# 1.项目尝试启动,生成项目启动yaml文件 kubectl create deployment springboot-k8s --image=38-springboot-k8s-1.0.0-jar --dry-run -o yaml > deploy.yaml
1.2 修改yaml文件,配置从本地拉取镜像
apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: hellok8s name: hellok8s spec: replicas: 1 selector: matchLabels: app: hellok8s strategy: {} template: metadata: creationTimestamp: null labels: app: hellok8s spec: containers: - image: hellok8s name: hellok8s imagePullPolicy: Never #从本地拉取镜像 resources: {} status: {}
1.3 执行命令,解析文件
kubectl apply -f boot-deploy.yaml (yaml是资源清单)
1.4 暴露pods端口
kubectl expose deployment springboot-k8s --port=8080 --type=NodePort
1.5 查看服务暴露端口
kubectl get services
标签:kubectl,配置文件,hellok8s,yaml,--,pod,k8s From: https://www.cnblogs.com/qxAndWorld/p/18215657