1. k8s redis 单节点部署
  2. kubectl 执行脚本
  3.  kubectl --kubeconfig ~/.kube-rz-real/config apply -f redis-leader.yaml -n rz-dt

vi redis-leader.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-leader-deploy
  labels:
    app: redis
    role: leader
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
        role: leader
        tier: backend
    spec:
      containers:
      - name: leader
        image: "anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/redis:5.0.3-8.6"
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
        - containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
  name: redis-leader-service
  labels:
    app: redis
    role: leader
    tier: backend
spec:
  type: NodePort #设定端口类型为节点型
  ports:
  - port: 6379
    targetPort: 6379
    nodePort: 32323 #新增此行可以将端口放到k8s集群外
  selector:
    app: redis
    role: leader
    tier: backend
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐