From debd08a0816c911f494e3ea015073773be05608f Mon Sep 17 00:00:00 2001 From: ycz008 Date: Tue, 2 Apr 2024 13:35:15 +0800 Subject: [PATCH] prod add k8snode and mysql --- prod-upgrade/kubesphere/k8s-cluster.yaml | 6 ++ prod-upgrade/mysql/mysql-0.yaml | 127 +++++++++++++++++++++++ prod-upgrade/mysql/mysql-1.yaml | 127 +++++++++++++++++++++++ prod-upgrade/mysql/mysql.yaml | 62 ----------- 4 files changed, 260 insertions(+), 62 deletions(-) create mode 100644 prod-upgrade/mysql/mysql-0.yaml create mode 100644 prod-upgrade/mysql/mysql-1.yaml delete mode 100644 prod-upgrade/mysql/mysql.yaml diff --git a/prod-upgrade/kubesphere/k8s-cluster.yaml b/prod-upgrade/kubesphere/k8s-cluster.yaml index 036a592..cc8730b 100644 --- a/prod-upgrade/kubesphere/k8s-cluster.yaml +++ b/prod-upgrade/kubesphere/k8s-cluster.yaml @@ -12,6 +12,8 @@ spec: - {name: bfs-k8snode-10-2-2-8.hetzner.base.beaconfireinc.com, address: 10.2.2.8, internalAddress: 10.2.2.8, privateKeyPath: "~/.ssh/bfs-ed25519"} - {name: bfs-k8snode-10-2-2-9.hetzner.base.beaconfireinc.com, address: 10.2.2.9, internalAddress: 10.2.2.9, privateKeyPath: "~/.ssh/bfs-ed25519"} - {name: bfs-k8snode-10-2-2-10.hetzner.base.beaconfireinc.com, address: 10.2.2.10, internalAddress: 10.2.2.10, privateKeyPath: "~/.ssh/bfs-ed25519"} + - {name: bfs-k8snode-10-2-2-90.hetzner.base.beaconfireinc.com, address: 10.2.2.90, internalAddress: 10.2.2.90, privateKeyPath: "~/.ssh/bfs-ed25519"} + - {name: bfs-k8snode-10-2-2-91.hetzner.base.beaconfireinc.com, address: 10.2.2.91, internalAddress: 10.2.2.91, privateKeyPath: "~/.ssh/bfs-ed25519"} roleGroups: etcd: - bfs-k8smaster-10-2-2-3.hetzner.base.beaconfireinc.com @@ -27,6 +29,10 @@ spec: - bfs-k8snode-10-2-2-8.hetzner.base.beaconfireinc.com - bfs-k8snode-10-2-2-9.hetzner.base.beaconfireinc.com - bfs-k8snode-10-2-2-10.hetzner.base.beaconfireinc.com + - bfs-k8snode-10-2-2-90.hetzner.base.beaconfireinc.com + - bfs-k8snode-10-2-2-91.hetzner.base.beaconfireinc.com + controlPlaneEndpoint: + controlPlaneEndpoint: controlPlaneEndpoint: ## Internal loadbalancer for apiservers # internalLoadbalancer: haproxy diff --git a/prod-upgrade/mysql/mysql-0.yaml b/prod-upgrade/mysql/mysql-0.yaml new file mode 100644 index 0000000..6766a45 --- /dev/null +++ b/prod-upgrade/mysql/mysql-0.yaml @@ -0,0 +1,127 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-m-cnf +data: + config: |- + [mysqld] + bind-address=0.0.0.0 + port=3306 + skip-name-resolve + basedir=/var/lib/mysql + datadir=/var/lib/mysql/data + log-bin=/var/lib/mysql/logs + plugin_dir=/var/lib/mysql/plugin + tmpdir=/var/lib/mysql/tmp + socket=/var/lib/mysql/mysql.sock + pid-file=/var/lib/mysql/mysqld.pid + log-error=/var/lib/mysql/logs/mysqld.log + max_allowed_packet=16M + character-set-server=utf8mb4 + collation-server=utf8mb4_unicode_ci + + # Extended + sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION + binlog_format=row + expire_logs_days=30 + max_connections=5000 + innodb_buffer_pool_size=4G + innodb_log_file_size=1G + innodb_flush_log_at_trx_commit=2 + sync_binlog=0 + + [client] + port=3306 + socket=/var/lib/mysql/mysql.sock + default-character-set=utf8mb4 + plugin_dir=/var/lib/mysql/plugin + + [manager] + port=3306 + socket=/var/lib/mysql/mysql.sock + pid-file=/var/lib/mysql/mysqld.pid + +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mysql-m +spec: + replicas: 1 + serviceName: mysql + selector: + matchLabels: + app: mysql-m + template: + metadata: + labels: + app: mysql-m + spec: + initContainers: + - name: init + image: busybox + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - | + sysctl -w net.ipv4.tcp_keepalive_time=300 + sysctl -w net.ipv4.tcp_keepalive_intvl=10 + sysctl -w net.ipv4.tcp_keepalive_probes=3 + securityContext: + privileged: true + containers: + - name: mysql + image: mysql:8.0.33 + ports: + - containerPort: 3306 + env: + - name: MYSQL_ROOT_PASSWORD + value: "Beaconfire@2099" + - name: MYSQL_DATABASE + value: "test" + - name: MYSQL_USER + value: "app" + - name: MYSQL_PASSWORD + value: "HelloBeaconfire!" + volumeMounts: + - name: mysql-m + mountPath: /var/lib/mysql + - name: mysql-m-cnf + mountPath: /etc/my.cnf + subPath: my.cnf + readOnly: true + volumes: + - name: mysql-m + hostPath: + path: /data/prod/mysql-m + - name: mysql-m-cnf + configMap: + name: mysql-m-cnf + items: + - key: config + path: my.cnf + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: "kubernetes.io/hostname" + operator: In + values: + - bfs-k8snode-10-2-2-90.hetzner.base.beaconfireinc.com +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql-m + labels: + app: mysql-m +spec: + ports: + - protocol: TCP + port: 3306 + targetPort: 3306 + selector: + app: mysql-m + type: ClusterIP \ No newline at end of file diff --git a/prod-upgrade/mysql/mysql-1.yaml b/prod-upgrade/mysql/mysql-1.yaml new file mode 100644 index 0000000..9bac84d --- /dev/null +++ b/prod-upgrade/mysql/mysql-1.yaml @@ -0,0 +1,127 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-s-cnf +data: + config: |- + [mysqld] + bind-address=0.0.0.0 + port=3306 + skip-name-resolve + basedir=/var/lib/mysql + datadir=/var/lib/mysql/data + log-bin=/var/lib/mysql/logs + plugin_dir=/var/lib/mysql/plugin + tmpdir=/var/lib/mysql/tmp + socket=/var/lib/mysql/mysql.sock + pid-file=/var/lib/mysql/mysqld.pid + log-error=/var/lib/mysql/logs/mysqld.log + max_allowed_packet=16M + character-set-server=utf8mb4 + collation-server=utf8mb4_unicode_ci + + # Extended + sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION + binlog_format=row + expire_logs_days=30 + max_connections=5000 + innodb_buffer_pool_size=4G + innodb_log_file_size=1G + innodb_flush_log_at_trx_commit=2 + sync_binlog=0 + + [client] + port=3306 + socket=/var/lib/mysql/mysql.sock + default-character-set=utf8mb4 + plugin_dir=/var/lib/mysql/plugin + + [manager] + port=3306 + socket=/var/lib/mysql/mysql.sock + pid-file=/var/lib/mysql/mysqld.pid + +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mysql-s +spec: + replicas: 1 + serviceName: mysql + selector: + matchLabels: + app: mysql-s + template: + metadata: + labels: + app: mysql-s + spec: + initContainers: + - name: init + image: busybox + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - | + sysctl -w net.ipv4.tcp_keepalive_time=300 + sysctl -w net.ipv4.tcp_keepalive_intvl=10 + sysctl -w net.ipv4.tcp_keepalive_probes=3 + securityContext: + privileged: true + containers: + - name: mysql + image: mysql:8.0.33 + ports: + - containerPort: 3306 + env: + - name: MYSQL_ROOT_PASSWORD + value: "Beaconfire@2099" + - name: MYSQL_DATABASE + value: "test" + - name: MYSQL_USER + value: "app" + - name: MYSQL_PASSWORD + value: "HelloBeaconfire!" + volumeMounts: + - name: mysql-s + mountPath: /var/lib/mysql + - name: mysql-s-cnf + mountPath: /etc/my.cnf + subPath: my.cnf + readOnly: true + volumes: + - name: mysql-s + hostPath: + path: /data/prod/mysql-s + - name: mysql-s-cnf + configMap: + name: mysql-s-cnf + items: + - key: config + path: my.cnf + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: "kubernetes.io/hostname" + operator: In + values: + - bfs-k8snode-10-2-2-91.hetzner.base.beaconfireinc.com +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql-s + labels: + app: mysql-s +spec: + ports: + - protocol: TCP + port: 3306 + targetPort: 3306 + selector: + app: mysql-s + type: ClusterIP \ No newline at end of file diff --git a/prod-upgrade/mysql/mysql.yaml b/prod-upgrade/mysql/mysql.yaml deleted file mode 100644 index b812605..0000000 --- a/prod-upgrade/mysql/mysql.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: v1 -kind: ReplicationController -metadata: - name: mysql - labels: - name: mysql -spec: - replicas: 1 - selector: - name: mysql - template: - metadata: - labels: - name: mysql - spec: - containers: - - name: mysql - image: mysql:8.0.33 - args: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--max_connections=2000", "--binlog_expire_logs_seconds=432000","--sql_mode =STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"] - ports: - - containerPort: 3306 - volumeMounts: - - name: mysql-data-prod - mountPath: /var/lib/mysql - env: - - name: MYSQL_ROOT_PASSWORD - value: "Beaconfire@2099" - - name: MYSQL_DATABASE - value: "devops" - - name: MYSQL_USER - value: "devops" - - name: MYSQL_PASSWORD - value: "Devops@2099" - volumes: - - name: mysql-data-prod - hostPath: - path: /data/prod/mysql - affinity: - nodeAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - nodeSelectorTerms: - - matchExpressions: - - key: "kubernetes.io/hostname" - operator: In - values: - - bfs-k8snode-10-2-2-6.hetzner.base.beaconfireinc.com ---- -apiVersion: v1 -kind: Service -metadata: - name: mysql - labels: - name: mysql -spec: - ports: - - protocol: TCP - port: 3306 - targetPort: 3306 - nodePort: 30012 - selector: - name: mysql - type: NodePort