新物理机如何加入K8s集群,详细信息请参见《Kubernetes 1.18.20 部署指南(CentOS&openEuler)》。
1 | vim mysql_deployment.yaml
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | ...... --- apiVersion: v1 kind: Pod metadata: name: mysql-1 ...... hostAliases: ...... - ip: "10.99.0.18" hostnames: - "mysql-4" ...... --- apiVersion: v1 kind: Pod metadata: name: mysql-2 ...... hostAliases: ...... - ip: "10.99.0.18" hostnames: - "mysql-4" ...... --- apiVersion: v1 kind: Pod metadata: name: mysql-3 ...... hostAliases: ...... - ip: "10.99.0.18" hostnames: - "mysql-4" ...... --- apiVersion: v1 kind: Pod metadata: labels: app: mysql-4 name: mysql-4 namespace: ns-mysql-test annotations: ovn.kubernetes.io/ip_address: 10.99.0.18 ovn.kubernetes.io/mac_address: 00:00:00:53:6B:B9 spec: nodeSelector: test: "mysql-test-4" hostAliases: - ip: "10.99.0.15" hostnames: - "mysql-1" - ip: "10.99.0.16" hostnames: - "mysql-2" - ip: "10.99.0.17" hostnames: - "mysql-3" - ip: "10.99.0.18" hostnames: - "mysql-4" containers: - name: mysql-4 image: mymysql/centos8-mysql-arm:8.0.19 resources: limits: cpu: 16 memory: 64Gi ports: - name: mysql-port containerPort: 3306 - name: copy-port containerPort: 33061 env: - name: MYSQL_ROOT_PASSWORD value: test123 - name: MYSQL_ROOT_HOST value: "%" volumeMounts: - name: mysql-data mountPath: "/data/mysql/data" - name: mysql-log mountPath: "/data/mysql/log" - name: mysql-run mountPath: "/data/mysql/run" - name: mysql-tmp mountPath: "/data/mysql/tmp" - name: mysql-cnf mountPath: "/etc/my.cnf" volumes: - name: mysql-data hostPath: path: "/data/mysql/mysql_4/data" type: DirectoryOrCreate - name: mysql-log hostPath: path: "/data/mysql/mysql_4/log" type: DirectoryOrCreate - name: mysql-run hostPath: path: "/data/mysql/mysql_4/run" type: DirectoryOrCreate - name: mysql-tmp hostPath: path: "/data/mysql/mysql_4/tmp" type: DirectoryOrCreate - name: mysql-cnf hostPath: path: "/data/mysql/mysql_4/mysql_arm.cnf" type: FileOrCreate ...... --- apiVersion: v1 kind: Service metadata: name: mysql-4-service namespace: ns-mysql-test spec: type: NodePort selector: app: mysql-4 ports: - name: dbport protocol: TCP port: 3306 targetPort: 3306 nodePort: 30004 - name: cpport protocol: TCP port: 33061 targetPort: 33061 nodePort: 30064 |
如上yaml修改: