kubernetes部署kubevious控制台
从helm获取yaml
kubectl create namespace kubevious
git clone https://github.com/kubevious/deploy.git kubevious-deploy.git
cd kubevious-deploy.git/kubernetes
helm template kubevious \
--namespace kubevious \
-f kubevious/values.latest.yaml \
> kubevious.yaml
获取yaml文件修改
mysql部分
ConfigMap kubevious-mysql-init-script
apiVersion: v1
kind: ConfigMap
metadata:
namespace: kubevious
name: kubevious-mysql-init-script
data:
initdb.sql: |
USE kubevious;
SET NAMES utf8mb4;
SET GLOBAL expire_logs_days = 3;
CREATE TABLE IF NOT EXISTS `config` (
`key` varchar(64) NOT NULL DEFAULT '',
`value` json NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `snapshots` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`date` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `snap_items` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`snapshot_id` int unsigned NOT NULL,
`dn` varchar(1024) NOT NULL DEFAULT '',
`kind` varchar(128) NOT NULL DEFAULT '',
`config-kind` varchar(128) NOT NULL DEFAULT '',
`name` varchar(128) NULL DEFAULT '',
`config` json NOT NULL,
PRIMARY KEY (`id`),
KEY `snapshot_id` (`snapshot_id`),
KEY `dn` (`dn`),
KEY `kind` (`kind`),
KEY `config-kind` (`config-kind`),
CONSTRAINT `snap_item_snapshot_id` FOREIGN KEY (`snapshot_id`) REFERENCES `snapshots` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `diffs` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`snapshot_id` int unsigned NOT NULL,
`date` datetime NOT NULL,
`in_snapshot` tinyint(1) NOT NULL,
`summary` json NOT NULL,
PRIMARY KEY (`id`),
KEY `snapshot_id` (`snapshot_id`),
KEY `date` (`date`),
CONSTRAINT `diff_snapshot_id` FOREIGN KEY (`snapshot_id`) REFERENCES `snapshots` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `diff_items` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`diff_id` int unsigned NOT NULL,
`dn` varchar(1024) NOT NULL DEFAULT '',
`kind` varchar(128) NOT NULL DEFAULT '',
`config-kind` varchar(128) NOT NULL DEFAULT '',
`name` varchar(128) NULL DEFAULT '',
`present` tinyint(1) NOT NULL,
`config` json DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `diff_id` (`diff_id`),
KEY `dn` (`dn`),
KEY `kind` (`kind`),
KEY `config-kind` (`config-kind`),
CONSTRAINT `diff_items_diff_id` FOREIGN KEY (`diff_id`) REFERENCES `diffs` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
svc mysql
kind: Service
apiVersion: v1
metadata:
name: kubevious-mysql-svc
namespace: kubevious
labels:
k8s-app: kubevious-mysql-svc
spec:
selector:
k8s-app: kubevious-mysql
clusterIP: None
ports:
- targetPort: 3306
protocol: TCP
port: 3306
ConfigMap kubevious-mysql-conf
apiVersion: v1
kind: ConfigMap
metadata:
namespace: kubevious
name: kubevious-mysql-conf
data:
master.cnf: |
# Apply this config only on the master.
[mysqld]
log-bin
expire_logs_days=3
slave.cnf: |
# Apply this config only on slaves.
[mysqld]
super-read-only
StatefulSet kubevious-mysql
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: kubevious
name: kubevious-mysql
spec:
selector:
matchLabels:
k8s-app: kubevious-mysql
serviceName: kubevious-mysql-svc
replicas: 1
template:
metadata:
labels:
k8s-app: kubevious-mysql
spec:
initContainers:
- name: init-mysql
image: mysql:5.7
command:
- bash
- "-c"
- |
set -ex
echo "[mysqld]" > /mnt/conf.d/server-id.cnf
echo "server-id=1" >> /mnt/conf.d/server-id.cnf
cp /mnt/config-map/master.cnf /mnt/conf.d/
volumeMounts:
- name: conf
mountPath: /mnt/conf.d
- name: config-map
mountPath: /mnt/config-map
containers:
- name: mysql
image: mysql:5.7
env:
- name: MYSQL_DATABASE
value: kubevious
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: "1"
ports:
- name: mysql
containerPort: 3306
volumeMounts:
- name: data
mountPath: /var/lib/mysql
subPath: mysql
- name: conf
mountPath: /etc/mysql/conf.d
- name: init-script
mountPath: /docker-entrypoint-initdb.d
resources:
requests:
cpu: 50m
memory: 500Mi
livenessProbe:
exec:
command: ["mysqladmin", "ping"]
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
readinessProbe:
exec:
# Check we can execute queries over TCP (skip-networking is off).
command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1
volumes:
- name: conf
emptyDir: {}
- name: config-map
configMap:
name: kubevious-mysql-conf
- name: init-script
configMap:
name: kubevious-mysql-init-script
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
#使用storageclass
volumeName:
storageClassName: nfs
kubevious
rbac
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubevious
namespace: kubevious
---
# Source: kubevious/templates/ui/serviceaccount.yaml
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubevious-ui
namespace: kubevious
---
# Source: kubevious/templates/server/clusterrole.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: kubevious
rules:
- apiGroups:
- ""
resources:
- namespaces
- services
- configmaps
- pods
- nodes
- limitranges
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- deployments
- statefulsets
- daemonsets
- replicasets
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- get
- list
- watch
- apiGroups:
- autoscaling
resources:
- horizontalpodautoscalers
verbs:
- get
- list
- watch
---
# Source: kubevious/templates/server/clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubevious
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubevious
subjects:
- kind: ServiceAccount
name: kubevious
namespace: kubevious
ConfigMap kubevious-mysql-client
apiVersion: v1
kind: ConfigMap
metadata:
namespace: kubevious
name: kubevious-mysql-client
data:
MYSQL_HOST: kubevious-mysql-0.kubevious-mysql-svc.kubevious.svc.cluster.local
MYSQL_PORT: "3306"
svc kubevious
kind: Service
apiVersion: v1
metadata:
name: kubevious-svc
namespace: kubevious
labels:
k8s-app: kubevious-svc
spec:
selector:
k8s-app: kubevious
ports:
- targetPort: 4000
protocol: TCP
port: 4000
---
# Source: kubevious/templates/ui/service.yaml
kind: Service
apiVersion: v1
metadata:
name: kubevious-ui-svc
namespace: kubevious
labels:
k8s-app: kubevious-ui-svc
spec:
type: NodePort
selector:
k8s-app: kubevious-ui
ports:
- targetPort: 3000
protocol: TCP
port: 3000
nodePort: 30005
Deployment kubevious kubevious-ui
kind: Deployment
apiVersion: apps/v1
metadata:
namespace: kubevious
name: kubevious
spec:
replicas: 1
selector:
matchLabels:
k8s-app: kubevious
template:
metadata:
labels:
k8s-app: kubevious
spec:
serviceAccountName: kubevious
containers:
- name: kubevious
image: "kubevious/kubevious:0.4.2"
imagePullPolicy: IfNotPresent
env:
- name: NODE_ENV
value: "production"
envFrom:
- configMapRef:
name: kubevious-mysql-client
ports:
- containerPort: 4000
name: http
resources:
requests:
cpu: 100m
memory: 200Mi
---
# Source: kubevious/templates/ui/deployment.yaml
---
kind: Deployment
apiVersion: apps/v1
metadata:
namespace: kubevious
name: kubevious-ui
spec:
replicas: 1
selector:
matchLabels:
k8s-app: kubevious-ui
template:
metadata:
labels:
k8s-app: kubevious-ui
spec:
serviceAccountName: kubevious-ui
containers:
- name: kubevious-ui
image: "kubevious/ui:0.4.1"
imagePullPolicy: IfNotPresent
env:
- name: NODE_ENV
value: "production"
- name: BACKEND_URL
value: "http://kubevious-svc.kubevious.svc.cluster.local:4000"
envFrom:
- configMapRef:
name: kubevious-mysql-client
ports:
- containerPort: 3000
name: http
resources:
requests:
cpu: 25m
memory: 100Mi