您的位置 首页 k8s

通过ReplicationController实现 数据共享 nfs- -configMap  配置文件共享

(ReplicationController 案例)通过rc控制器实现 数据共享 nfs- -configMap  配置文件共享

ReplicationController 副本控制器-第一个控制器
	kubectl  explain rc.spec
	kubectl get rc
	kubectl delete rc  name

案例:

cat 01-rc-nginx.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx.conf
data:
  nginx.conf: |
    user  nginx;
    worker_processes  auto;
    error_log  /var/log/nginx/error.log notice;
    pid        /var/run/nginx.pid;
    events {
        worker_connections  1024;
    }
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
        access_log  /var/log/nginx/access.log  main;
        sendfile        on;
        keepalive_timeout  65;
        include /etc/nginx/conf.d/*.conf;
    }

---

apiVersion: v1
kind: ReplicationController
metadata:
  name: baimei-rc
spec:
  # 表示运行几个Pod副本数量
  replicas: 7
  # 创建Pod的模板
  template:
    metadata:
      labels:
        apps: web
    spec:
      volumes:
      - name: data
        nfs:
          server: master231
          path: /baimei/data/kubernetes
      - name: etc
        configMap:
          name: nginx.conf
          items:
          - key: nginx.conf
            path: nginx.conf
      containers:
      - name: web
        image: harbor.baimei.com/baimei-web/nginx:1.25.1-alpine
        volumeMounts:
        - name: data
          mountPath: /usr/share/nginx/html
        - name: etc
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf

运行:

kubectl apply -f 01-rc-nginx.yaml

 

kubectl get rc

 

kubectl  get pods -o wide --show-labels

删除 rc

kubectl delete rc  baimei-rc

 

通过service 控制器实现负载均衡案例 : 连接

欢迎来撩 : 汇总all

白眉大叔

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

热门文章