您的位置 首页 k8s

使用deployment部署redis案例:

使用deployment部署redis案例:

1.导入镜像

wget http://192.168.11.253/Kubernetes/day06-/images/redis-6.0.5.tar.gz
docker tag redis:6.0.5 harbor.baimei.com/baimei-db/redis:6.0.5
docker push harbor.baimei.com/baimei-db/redis:6.0.5

2.使用deployment部署redis

cat 04-deploy-redis.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-leader
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: leader
        image: harbor.baimei.com/baimei-db/redis:6.0.5
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
        - containerPort: 6379

---

apiVersion: v1
kind: Service
metadata:
  name: redis-leader
spec:
  type: NodePort
  ports:
  - port: 6379
    targetPort: 6379
    nodePort: 6379
  selector:
    app: redis
 kubectl apply -f  04-deploy-redis.yaml

3.测试链接redis环境

 kubectl get pods
kubectl exec -it redis-leader-688fc96f5f-9plzq -- bash

 

root@redis-leader-688fc96f5f-9plzq:/data# redis-cli 
127.0.0.1:6379> 
127.0.0.1:6379> KEYS *
(empty array)
127.0.0.1:6379> 
127.0.0.1:6379> set school baimei
OK
127.0.0.1:6379> KEYS *

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章