# DevOps 云环境部署
# 数据库初始化
按顺序依次在数据库中执行 devops-ddl-all.sql
和 devops-data-all.sql
这两个文件(可从 war 包中获取),进行 DevOps 的数据库初始化
# Namespace
$ kubectl create namespace devops
# DevOps 证书
利用 K8S ConfigMap 存放 DevOps 证书信息,其内容如下(devops-license.yml)
---
apiVersion: v1
kind: ConfigMap
metadata:
name: devops-license
namespace: devops
data:
primetonlicense.xml: |-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenses>
<license-group embed="true" format="1.0" productFamily="Primeton DevOps" release="V6">
<license edition="EE" licensee="Primeton Customer" sign="14c87ef256d833e4f7e38fc564305b68e695694af14e3cbcbfc95901f223490a33dcc3a0f09e17c40983b2a356d459fc61e71b75ea69ecb6d813f6d73f25d16866716da1cb08f1dd29d741a1ee00b33f12c654c6c767165b3241ff809c61735c8850f90feb5d3049117eaf64603f3e3e964afe0b53bbc997b84d88294cc10dc4" type="PERM">
<license-element key="cpus" privilege="true" value="unlimited"/>
<license-element key="db" value="unlimited"/>
<license-element key="as" value="unlimited"/>
<license-element key="os" value="unlimited"/>
<license-element key="expiration" value="unlimited"/>
<license-element key="ip" value="JIcj147xiobDk06SDS62mcB4k6i2f0ZyVw=="/>
<license-element key="mac" value="JIcj147xiobDk06SDS62mcB4k6i2f0ZyVw=="/>
<license-element key="server" value="true">
</license-element>
<license-element key="richweb" value="true">
</license-element>
<license-element key="workflow" value="true">
</license-element>
<license-element key="managermodel" value="group"/>
<license-element key="cluster" value="true"/>
<license-element key="international" value="unlimited"/>
<license-element key="concurrency" value="5"/>
<license-element key="distributed" value="false"/>
<license-element key="scaAssembly" value="true"/>
<license-element key="scaCaller" value="true"/>
<license-element key="wsBinding" value="true"/>
<license-element key="wsCaller" value="true"/>
<license-element dynamic="true" key="user_count" value="2"/>
<license-element dynamic="true" key="project_count" value="2"/>
</license>
</license-group>
</licenses>
发布 ConfigMap
$ kubectl create -f devops-license.yml
# 服务部署
devops-deployment.yml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: devops
namespace: devops
spec:
replicas: 1
selector:
matchLabels:
app: devops
template:
metadata:
labels:
app: devops
spec:
containers:
- name: devops
image: 172.16.62.204:30085/puyuan/devops:6.3.0.0-GA
imagePullPolicy: Always
env:
- name: JAVA_OPTS # JVM参数以及数据库连接配置
value: "-server -Xms2048m -Xmx2048m -Ddb.url='jdbc:mysql://mysql:3306/devops?characterEncoding=UTF-8&useSSL=false' -Ddb.userName='root' -Ddb.password='password'"
ports:
- containerPort: 8080
name: api
protocol: TCP
resources:
limits:
cpu: 1000m
memory: 3Gi
requests:
cpu: 1000m
memory: 3Gi
volumeMounts:
- name: config
mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/_srv/primetonlicense.xml # DevOps 证书存放位置
subPath: primetonlicense.xml
- name: data
mountPath: /usr/local/tomcat/_work_ROOT_6200 # DevOps工作目录(存放日志、流水线实例详情以及附件等文件)
volumes:
- name: config
configMap:
defaultMode: 0644
name: devops-license
- name: data
persistentVolumeClaim:
claimName: devops-data
部署 DevOps 服务
$ kubectl create -f devops-deployment.yml
# 服务暴漏
devops-svc.yml
---
apiVersion: v1
kind: Service
metadata:
name: devops
namespace: devops
labels:
app: devops
spec:
selector:
app: devops
type: NodePort
ports:
- name: api
port: 8080
targetPort: api
nodePort: 30080
暴露 DevOps 服务供外部访问
$ kubectl create -f devops-svc.yml