通过kubernetes构建ela服务

时间:2023-12-09 13:32:43

一、kubernetes 通过yaml 创建pod与service

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ela
spec:
replicas:
template:
metadata:
labels:
name: ela
spec:
containers:
- name: ela
image: 59.61.79.157:/ela
tty: true
ports:
- containerPort:
- containerPort:
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:
targetPort:
# nodePort:
protocol: TCP
name: elasql
- port:
targetPort:
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. images not ifconfig commod   #yum -y install net-tools