测试环境k8s部署 发表于 2019-11-19 | 更新于 2020-01-09 | 分类于 linux 测试环境k8s部署 测试环境k8s部署123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283apiVersion: v1 kind: ReplicationController metadata: name: redis-master labels: name: redis-master spec: replicas: 1 selector: name: redis-master template: metadata: labels: name: redis-master spec: containers: - name: redis-master image: 192.168.106.117/library/redis:3.2.9 ports: - containerPort: 6379 volumeMounts: - name: redis-config-pvc mountPath: "/usr/local/etc/redis/" command: ["redis-server","/usr/local/etc/redis/redis-master.conf"] volumes: - name: redis-config-pvc persistentVolumeClaim: claimName: redis-config-pvc--------apiVersion: v1 kind: Service metadata: name: redis-master labels: name: redis-master spec: ports: - port: 6379 targetPort: 6379 selector: name: redis-master--------------------apiVersion: v1kind: Podmetadata: labels: name: busybox-test-dns role: master name: busyboxspec: containers: - name: busybox image: 192.168.106.117/library/busybox:latest command: - sleep - "3600" ---------------------apiVersion: v1 kind: ReplicationController metadata: name: redis-slave labels: name: redis-slave spec: replicas: 1 selector: name: redis-slave template: metadata: labels: name: redis-slave spec: containers: - name: redis-slave image: 192.168.106.117/library/redis:3.2.9 command: ["redis-server","/usr/local/etc/redis/redis-slave.conf"] ports: - containerPort: 6379 volumeMounts: - name: redis-config-pvc mountPath: "/usr/local/etc/redis/" volumes: - name: redis-config-pvc persistentVolumeClaim: claimName: redis-config-pvc -------------------------------apiVersion: v1 kind: Service metadata: name: redis-slave labels: name: redis-slave spec: ports: - port: 6379 targetPort: 6379 selector: name: redis-slave ----------------------------------------------# 创建redis-config-pvc存放redis config文件#masterport 6379bind 0.0.0.0#daemonize yesmasterauth "123456"requirepass "123456"timeout 0rdbcompression yesdbfilename "redis.rdb"dir "/data"maxmemory 50gbmaxmemory-policy noevictionclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60notify-keyspace-events "gxE"#slaveport 6379bind 0.0.0.0logfile "redis6500.log"pidfile "6500.pid"masterauth "123456"requirepass "123456"slave-read-only yesslave-priority 100timeout 0rdbcompression yesdbfilename "redis.rdb"dir "/data"maxmemory 50gbmaxmemory-policy noevictionclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60slaveof redis-master 6379#sentinelport 6379protected-mode nodir "/data"sentinel myid bf64f29ff9578fb293d5d90ec85d083e2ae03725sentinel monitor mymaster redis-master 6379 1sentinel down-after-milliseconds mymaster 5000sentinel failover-timeout mymaster 18000sentinel auth-pass mymaster 123456sentinel config-epoch mymaster 8735sentinel leader-epoch mymaster 8735sentinel known-slave mymaster redis-slave 6379sentinel current-epoch 8735----------------------------------apiVersion: v1 kind: ReplicationController metadata: name: redis-sentinel labels: name: redis-sentinel spec: replicas: 1 selector: name: redis-sentinel template: metadata: labels: name: redis-sentinel spec: containers: - name: redis-sentinel image: 192.168.106.117/library/redis:3.2.9 command: ["redis-sentinel","/usr/local/etc/redis/sentinel.conf"] ports: - containerPort: 6379 volumeMounts: - name: redis-config-pvc mountPath: "/usr/local/etc/redis/" volumes: - name: redis-config-pvc persistentVolumeClaim: claimName: redis-config-pvc -------------------------------apiVersion: v1 kind: Service metadata: name: redis-sentinel labels: name: redis-sentinel spec: ports: - port: 6379 targetPort: 6379 selector: name: redis-sentinel ----------------------------------------------创建tomcat 的 pvc----------------------------------apiVersion: v1 kind: ReplicationController metadata: name: tomcat-infoverisystem labels: name: tomcat-infoverisystemspec: replicas: 1 selector: name: tomcat-infoverisystem template: metadata: labels: name: tomcat-infoverisystem spec: containers: - name: tomcat-infoverisystem image: 192.168.106.117/library/tomcat:8.5.35 ports: - containerPort: 8080 volumeMounts: - name: tomcat-war-pvc mountPath: "/usr/local/tomcat/webapps" volumes: - name: tomcat-war-pvc persistentVolumeClaim: claimName: tomcat-war-pvc -------------------------------apiVersion: v1 kind: Service metadata: name: tomcat-infoverisystem labels: name: tomcat-infoverisystem spec: ports: - port: 8080 targetPort: 8080 selector: name: tomcat-infoverisystem ----------------------------------------------apiVersion: extensions/v1beta1kind: Ingressmetadata: name: tomcat-infoverisystem annotations: kubernets.io/ingress.class: "nginx"spec: rules: - http: paths: - path: backend: serviceName: tomcat-infoverisystem servicePort: 8080