129 lines
2.2 KiB
Markdown
129 lines
2.2 KiB
Markdown
### mysql-cli
|
|
|
|
```yaml
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: mysql-cli
|
|
namespace: cli
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: mysql-cli
|
|
replicas: 1
|
|
serviceName: mysql-cli-svc
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: mysql-cli
|
|
spec:
|
|
containers:
|
|
- image: mysql:5.7.41
|
|
name: mysql-cli-pod
|
|
env:
|
|
- name: MYSQL_ROOT_PASSWORD
|
|
value: Sunqi0220.
|
|
- name: LANG
|
|
value: C.UTF-8
|
|
```
|
|
|
|
### redis-cli
|
|
|
|
```yaml
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: redis-cli
|
|
namespace: cli
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: redis-cli
|
|
replicas: 1
|
|
serviceName: redis-cli-svc
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: redis-cli
|
|
spec:
|
|
containers:
|
|
- image: redis:5.0
|
|
name: redis-cli-pod
|
|
command: ["/bin/sh"]
|
|
args: ["-c","while true;do echo ${date};sleep 3600;done"]
|
|
env:
|
|
- name: LANG
|
|
value: C.UTF-8#
|
|
```
|
|
|
|
### rails-cli
|
|
|
|
```yaml
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: rails-cli
|
|
namespace: cli
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: rails-cli
|
|
replicas: 1
|
|
serviceName: rails-cli
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: rails-cli
|
|
spec:
|
|
containers:
|
|
- image: ruby:3.1.4-buster
|
|
name: rails-cli-pod
|
|
command: [ "/bin/sh", "-c"]
|
|
args: ["gem sources -r https://rubygems.org/;gem sources -a https://gems.ruby-china.com;gem sources -l;while true; do sleep 30000; done;"]
|
|
volumeMounts:
|
|
- mountPath: /data
|
|
name: rails-volume
|
|
volumes:
|
|
- name: rails-volume
|
|
hostPath:
|
|
# directory location on host
|
|
path: /root/code-server/k8s/rails_data
|
|
# this field is optional
|
|
type: Directory
|
|
```
|
|
|
|
### svc.yaml
|
|
|
|
```yaml
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: mysql-cli-svc
|
|
namespace: cli
|
|
labels:
|
|
app: mysql-cli-svc
|
|
spec:
|
|
ports:
|
|
- port: 3306
|
|
name: mysql
|
|
clusterIP: None
|
|
selector:
|
|
app: mysql-cli
|
|
-----
|
|
appiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: redis-cli-svc
|
|
namespace: cli
|
|
labels:
|
|
app: mysql-cli-svc
|
|
spec:
|
|
ports:
|
|
- port: 6379
|
|
name: redis
|
|
clusterIP: None
|
|
selector:
|
|
app: redis-cli
|
|
```
|
|
|