怎样通过k8s部署superset镜像?
时间: 2023-11-03 10:05:15 浏览: 197
步骤如下:
1. 安装k8s
2. 部署数据库
本例以MySQL为例,可通过以下命令在k8s中创建一个MySQL实例:
```
kubectl create -f mysql.yaml
```
其中mysql.yaml的内容如下:
```
apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql
spec:
ports:
- name: mysql
port: 3306
selector:
app: mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
replicas: 1
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
```
3. 部署superset
可以通过以下命令在k8s中创建一个superset实例:
```
kubectl create -f superset.yaml
```
其中superset.yaml的内容如下:
```
apiVersion: v1
kind: Service
metadata:
name: superset
labels:
app: superset
spec:
ports:
- name: http
port: 8088
selector:
app: superset
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: superset
spec:
selector:
matchLabels:
app: superset
replicas: 1
template:
metadata:
labels:
app: superset
spec:
containers:
- name: superset
image: amancevice/superset
env:
- name: SUPERSET_CONFIG
value: /etc/superset/superset_config.py
- name: SUPERSET_HOME
value: /etc/superset
- name: SQLALCHEMY_DATABASE_URI
value: mysql://root:password@mysql:3306/superset
ports:
- containerPort: 8088
volumeMounts:
- name: superset-persistent-storage
mountPath: /etc/superset
volumes:
- name: superset-persistent-storage
persistentVolumeClaim:
claimName: superset-pv-claim
```
4. 访问superset
在浏览器中输入`http://localhost:8088`,即可访问superset。
阅读全文