zoukankan      html  css  js  c++  java
  • k8s第一个实例创建redis集群服务

    1、创建redis-master-controller.yaml

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: redis-master
      labels:
        name: redis-master
    spec:
      replicas: 2
      selector:
        name: redis-master
      template:
        metadata:
          labels:
            name: redis-master
        spec:
          containers:
          - name: master
            image: redis
            ports:
            - containerPort: 6379

    运行该实例:

    kubectl  create -f redis-master-controller.yaml

    2、创建redis-master-service.yaml

    apiVersion: v1
    kind: Service
    metadata:
      name: redis-master
      labels:
        name: redis-master
    spec:
      selector:
        name: redis-master
      ports:
      - port: 6379
        targetPort: 6379

    运行 master-service

      kubectl create -f redis-master-service.yaml

    3、创建 redis-slave-controller.yaml

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: redis-slave
      labels:
        name: redis-slave
    spec:
      replicas: 2
      selector:
        name: redis-slave
      template:
        metadata:
          labels:
            name: redis-slave
        spec:
          containers:
          - name: slave
            image: kubeguide/guestbook-redis-slave
            ports:
            - containerPort: 6379
            env:
            - name: GET_HOSTS_FROM
              value: env

    运行:

    kubectl create -f redis-slave-controller.yaml

    4、创建 redis-slave-controller.yaml

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: redis-slave
      labels:
        name: redis-slave
    spec:
      replicas: 2
      selector:
        name: redis-slave
      template:
        metadata:
          labels:
            name: redis-slave
        spec:
          containers:
          - name: slave
            image: kubeguide/guestbook-redis-slave
            ports:
            - containerPort: 6379
            env:
            - name: GET_HOSTS_FROM
              value: env

    运行   kubectl create -f redis-slave-controller.yaml

    5、创建  redis-slave-service.yaml

    apiVersion: v1
    kind: Service
    metadata:
      name: redis-slave
      labels:
        name: redis-slave
    spec:
      selector:
        name: redis-slave
      ports:
      - port: 6379

    运行  

    kubectl create -f redis-slave-service.yaml

    查看运行pods

    [root@k8s_ceshi mall-abbott]# kubectl get pods
    NAME READY STATUS RESTARTS AGE
    frontend-14jz9 0/1 ContainerCreating 0 15m
    frontend-h6v6b 0/1 ContainerCreating 0 15m
    frontend-ld67s 0/1 ContainerCreating 0 15m
    redis-master-8ck0d 0/1 ContainerCreating 0 20m
    redis-master-vg19j 0/1 ContainerCreating 0 20m
    redis-slave-56l6b 0/1 ContainerCreating 0 17m
    redis-slave-5h0rv 0/1 ContainerCreating 0 17m

    在创建的过程中一定要按照格式来写,尤其是空格,对于自由写代码的coder来说,这个格式简直是折磨人啊!!!!!

  • 相关阅读:
    HTML和XHTML知识总结
    理解margin-left:-100%
    git clean的用法
    vue路由传参的三种基本方式
    vertical-align属性
    纯CSS制作各种图形(多图预警)
    css伪元素:before和:after用法详解
    前端注册登录的业务流程
    Vue-cli 中为单独页面设置背景图片铺满全屏的方法
    vscode 开启对 webpack alias(文件别名) 引入的智能提示
  • 原文地址:https://www.cnblogs.com/itor/p/8057670.html
Copyright © 2011-2022 走看看