一、kubernetes 通过yaml 创建pod与service
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: ela spec: replicas: 1 template: metadata: labels: name: ela spec: containers: - name: ela image: 59.61.79.157:5000/ela tty: true ports: - containerPort: 9200 - containerPort: 8080 volumeMounts: - name: ssl-certs mountPath: /eladata volumes: - name: ssl-certs hostPath: emptyDir: {} --- apiVersion: v1 kind: Service metadata: name: ela labels: name: ela spec: type: NodePort ports: - port: 8080 targetPort: 8080 # nodePort: 30001 protocol: TCP name: elasql - port: 9200 targetPort: 9200 protocol: TCP name: elas selector: name: ela
二、kubectl常用命令
kubectl delete deployment * 删除部署 kubectl create -f k8s.yaml 创建服务 kubectl apply -f k8s.yaml 更新服务 kubectl get pods 查看容器 kubectl get deployment 查看部署 kubectl get service 查看服务 kubectl get node 查看集群 kubectl get pods -o wide 查看服务运行在哪个节点
三、其他
删除镜像:(非管理员勿操作) docker exec registry rm -rf /var/lib/registry/docker/registry/v2/repositories/<镜像名> docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml 详情: #centos7.2 images not ifconfig commod #yum -y install net-tools