k8s部署常用服务的yaml文件
程序员文章站
2024-03-09 10:04:23
...
1、k8s部署tomcat的yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: mytomcat
spec:
replicas: 3
selector:
matchLabels:
app: mytomcat
minReadySeconds: 1
progressDeadlineSeconds: 60
revisionHistoryLimit: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
name: mytomcat
labels:
app: mytomcat
spec:
containers:
- name: mytomcat
image: tomcat:8
ports:
- containerPort: 8080
volumeMounts:
- name: tz-config
mountPath: /etc/localtime
volumes:
- name: tz-config
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
2、k8s部署tomcat的svc文件
apiVersion: v1
kind: Service
metadata:
name: mytomcat
spec:
type: NodePort
ports:
- port: 8080
nodePort: 30012
selector:
app: mytomcat
3、k8s部署java的yaml文件
version: "3.6"
services:
dev-11100:
image: java:8u111-jdk
container_name: dev-11100
ports:
- 11100:8088
- 21100:5555
restart: always
working_dir: /opt/app
volumes:
- ../app:/opt/app
- /etc/localtime:/etc/localtime:ro
command: java -Duser.timezone=GMT+08 -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5555 -Xms256M -Xmx512M web.jar --spring.profiles.active=dev
4、k8s部署mysql的yaml文件
version: "3.6"
services:
mysql:
image: mysql:5.7
container_name: mysql
ports:
- 3306:3306
restart: always
environment:
- MYSQL_ROOT_PASSWORD=root
volumes:
- ../datadir:/var/lib/mysql
- ../conf.d/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf #注意文件位置,跟yml文件
- /etc/localtime:/etc/localtime:ro
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --init-connect='SET NAMES utf8mb4;' --innodb-flush-log-at-trx-commit=0
5、k8s部署nginx的yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
minReadySeconds: 1
progressDeadlineSeconds: 60
revisionHistoryLimit: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.19.2
ports:
- containerPort: 80
6、k8s部署gitlab的yaml文件
version: "3.6"
services:
gitlab-ce:
image: gitlab/gitlab-ce:12.0.2-ce.0
container_name: gitlab-ce
hostname: 192.168.1.15
ports:
- "8086:80"
- "8087:443"
- "8088:22"
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
#external_url 'https://192.168.1.15:8087'
gitlab_rails['lfs_enabled'] = true
gitlab_rails['backup_keep_time'] = 604800
gitlab_rails['gitlab_shell_ssh_port'] = 8088
volumes:
- /etc/localtime:/etc/localtime:ro
- ../datadir/gitlab/config:/etc/gitlab
- ../datadir/gitlab/logs:/var/log/gitlab
- ../datadir/gitlab/data:/var/opt/gitlab
7、k8s部署jenkins的yaml文件
version: "3.6"
services:
jenkins:
image: jenkins/jenkins:2.181
container_name: jenkins
user: root
ports:
- "8080:8080"
- "50000:50000"
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ../software:/opt/software
- /usr/bin/docker:/usr/bin/docker:ro
- ../jenkins_home:/var/jenkins_home
- /etc/localtime:/etc/localtime:ro
8、k8s部署nexus的yaml文件
version: "3.6"
services:
nexus:
image: sonatype/nexus3:3.16.2
container_name: nexus
ports:
- 8081:8081
restart: always
user: root
volumes:
- ../nexus-data:/nexus-data
- /etc/localtime:/etc/localtime:ro
上一篇: go递归打印指定目录下的所有文件及文件夹