Commit 3290bf66 authored by 梦良's avatar 梦良

修改Jenkins、chart

parent d7bc3128
......@@ -996,7 +996,7 @@ func (c *JobController) StartRunPipelineJob() {
infoLogger.Printf("启动运行job:%s成功", jobName)
responseDto.Status = 200
responseDto.Message = "成功"
responseDto.Message = "启动运行成功"
c.Data["json"] = responseDto
c.ServeJSON()
}
......
apiVersion: v1
appVersion: "2.0"
description: A Helm chart for Kubernetes
name: k8s-console
name: k8s-devops
version: 2.0
......@@ -4,16 +4,16 @@
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "k8s-console.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "k8s-devops.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "k8s-console.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "k8s-console.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
You can watch the status of by running 'kubectl get svc -w {{ include "k8s-devops.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "k8s-devops.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "k8s-console.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "k8s-devops.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
......@@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "k8s-console.name" -}}
{{- define "k8s-devops.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
......@@ -11,7 +11,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "k8s-console.fullname" -}}
{{- define "k8s-devops.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
......@@ -27,6 +27,6 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "k8s-console.chart" -}}
{{- define "k8s-devops.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
......@@ -3,16 +3,16 @@ kind: Deployment
metadata:
name: {{ .Release.Name }}
labels:
app: {{ include "k8s-console.name" . }}
app: {{ include "k8s-devops.name" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ include "k8s-console.name" . }}
app: {{ include "k8s-devops.name" . }}
template:
metadata:
labels:
app: {{ include "k8s-console.name" . }}
app: {{ include "k8s-devops.name" . }}
spec:
# volumes:
# - name: tz-config
......
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "k8s-console.fullname" . -}}
{{- $fullName := include "k8s-devops.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "k8s-console.name" . }}
helm.sh/chart: {{ include "k8s-console.chart" . }}
app.kubernetes.io/name: {{ include "k8s-devops.name" . }}
helm.sh/chart: {{ include "k8s-devops.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app: {{ include "k8s-console.name" . }}
app: {{ include "k8s-devops.name" . }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
......
{{- $fullName := include "k8s-console.fullname" . -}}
{{- $fullName := include "k8s-devops.fullname" . -}}
apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}
labels:
app: {{ include "k8s-console.name" . }}
app: {{ include "k8s-devops.name" . }}
spec:
type: {{ .Values.service.type }}
ports:
......@@ -13,4 +13,4 @@ spec:
protocol: TCP
name: http
selector:
app: {{ include "k8s-console.name" . }}
app: {{ include "k8s-devops.name" . }}
......@@ -6,16 +6,16 @@ replicaCount: 1
global:
hub: harbor.dev.k2paas.com/paas-dev
image:
repository: paas-k8s-console
repository: paas-devops
tag: dev
pullPolicy: IfNotPresent
nameOverride: "k8s-console"
fullnameOverride: "k8s-console"
nameOverride: "devops"
fullnameOverride: "devops"
service:
type: ClusterIP
port: 8020
port: 8080
ingress:
enabled: true
......@@ -34,7 +34,7 @@ ingress:
#kubernetes.io/tls-acme: "true"
path: /
web:
host: console.dev.k2paas.com
host: devops.dev.k2paas.com
port: http
tls: []
# - secretName: k8s-console-server-tls
......
......@@ -6,16 +6,16 @@ replicaCount: 1
global:
hub: harbor.test.k2paas.com/paas-test
image:
repository: paas-k8s-console
repository: paas-devops
tag: test
pullPolicy: IfNotPresent
nameOverride: "k8s-console"
fullnameOverride: "k8s-console"
nameOverride: "devops"
fullnameOverride: "devops"
service:
type: ClusterIP
port: 8020
port: 8080
ingress:
enabled: true
......@@ -34,7 +34,7 @@ ingress:
# nginx.ingress.kubernetes.io/ssl-redirect: "true"
path: /
web:
host: console.test.k2paas.com
host: devops.test.k2paas.com
port: http
tls: []
......
......@@ -6,16 +6,16 @@ replicaCount: 1
global:
hub: harbor.k2software.com.cn/library
image:
repository: paas-k8s-console
repository: paas-devops
tag: prod
pullPolicy: IfNotPresent
nameOverride: "k8s-console"
fullnameOverride: "k8s-console"
nameOverride: "devops"
fullnameOverride: "devops"
service:
type: ClusterIP
port: 8020
port: 8080
ingress:
enabled: true
......@@ -34,7 +34,7 @@ ingress:
# nginx.ingress.kubernetes.io/ssl-redirect: "true"
path: /
web:
host: console.k2software.com.cn
host: devops.k2software.com.cn
port: http
tls: []
# - secretName: k8s-console-server-tls
......
......@@ -49,7 +49,7 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
]) {
node(label) {
def version = "v5.1"
def version = "v6.0"
stage('checkout') {
checkout scm
......@@ -60,17 +60,17 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
stage('build') {
sh 'ls -al'
// 生成静态链接所有的库
sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -v -mod vendor -o k8s-console'
sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -v -mod vendor -o devops'
}
stage('copy-front') {
def dist_dir = "/mnt/k8s/online/${version}/front/k8s_console_front/dist"
def dist_dir = "/mnt/k8s/online/${version}/front/devops_front/dist"
sh "cp -r $dist_dir frontend/"
}
}
container('docker') {
//def tarName = "/mnt/k8s/online/${version}/images/paas-k8s-console_dev-${env.BUILD_ID}.tar"
//def tarName = "/mnt/k8s/online/${version}/images/paas-devops_dev-${env.BUILD_ID}.tar"
stage('docker-login') {
//REGISTRY_URL私有仓库地址,也可使用官方地址:docker.io
......@@ -78,33 +78,33 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
}
stage('docker-build') {
sh "docker build . -t ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID}"
sh "docker build . -t ${params.REGISTRY_URL}/paas-dev/paas-devops:dev-${env.BUILD_ID}"
}
stage('docker-push') {
sh "docker push ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID}"
sh "docker push ${params.REGISTRY_URL}/paas-dev/paas-devops:dev-${env.BUILD_ID}"
}
// stage('docker-save') {
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-k8s-console_*.tar"
// sh "docker save ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID} > $tarName"
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-devops_*.tar"
// sh "docker save ${params.REGISTRY_URL}/paas-dev/paas-devops:dev-${env.BUILD_ID} > $tarName"
// }
stage('docker-rmi') {
sh "docker rmi ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID}"
sh "docker rmi ${params.REGISTRY_URL}/paas-dev/paas-devops:dev-${env.BUILD_ID}"
}
}
container('helm') {
stage('helm deploy') {
sh "sed -i \"s/tag: dev/tag: dev-${env.BUILD_ID}/g\" k8s-console-chart/values-dev.yaml"
sh "helm upgrade --install k8s-console --namespace paas k8s-console-chart/ -f k8s-console-chart/values-dev.yaml"
sh "sed -i \"s/tag: dev/tag: dev-${env.BUILD_ID}/g\" devops-chart/values-dev.yaml"
//sh "helm upgrade --install devops --namespace paas devops-chart/ -f devops-chart/values-dev.yaml"
def previewTarget = "/mnt/k8s/online/${version}/charts"
if(!fileExists("${previewTarget}")) {
sh "mkdir -p ${previewTarget}"
}
sh "cp -r k8s-console-chart ${previewTarget}/"
sh "cp -r devops-chart ${previewTarget}/"
}
}
}
......
......@@ -28,7 +28,7 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
]) {
node(label) {
def version = "v5.1"
def version = "v6.0"
stage('checkout') {
checkout scm
......@@ -38,20 +38,18 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
container('golang') {
stage('build') {
sh 'ls -al'
sh "sed -i 's#appstore-server-url = http://appstore.dev.k2paas.com#appstore-server-url = https://apps.k2software.com.cn#g' conf/app.conf"
sh "sed -i 's#http://tenant.dev.k2paas.com#https://tenant.k2software.com.cn#g' conf/app.conf"
// 生成静态链接所有的库
sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -v -mod vendor -o k8s-console'
}
stage('copy-front') {
def dist_dir = "/mnt/k8s/online/${version}/front/k8s_console_front/dist"
def dist_dir = "/mnt/k8s/online/${version}/front/devops_front/dist"
sh "cp -r $dist_dir frontend/"
}
}
container('docker') {
//def tarName = "/mnt/k8s/online/${version}/images/paas-k8s-console_${version}-${env.BUILD_ID}.tar"
//def tarName = "/mnt/k8s/online/${version}/images/paas-devops_${version}-${env.BUILD_ID}.tar"
stage('docker-login') {
//REGISTRY_URL私有仓库地址,也可使用官方地址:docker.io
......@@ -59,33 +57,33 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
}
stage('docker-build') {
sh "docker build . -t ${params.REGISTRY_URL}/library/paas-k8s-console:${version}-${env.BUILD_ID}"
sh "docker build . -t ${params.REGISTRY_URL}/library/paas-devops:${version}-${env.BUILD_ID}"
}
stage('docker-push') {
sh "docker push ${params.REGISTRY_URL}/library/paas-k8s-console:${version}-${env.BUILD_ID}"
sh "docker push ${params.REGISTRY_URL}/library/paas-devops:${version}-${env.BUILD_ID}"
}
//stage('docker-save') {
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-k8s-console_*.tar"
// sh "docker save ${params.REGISTRY_URL}/library/paas-k8s-console:${version}-${env.BUILD_ID} > $tarName"
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-devops_*.tar"
// sh "docker save ${params.REGISTRY_URL}/library/paas-k8s-devops:${version}-${env.BUILD_ID} > $tarName"
//}
stage('docker-rmi') {
sh "docker rmi ${params.REGISTRY_URL}/library/paas-k8s-console:${version}-${env.BUILD_ID}"
sh "docker rmi ${params.REGISTRY_URL}/library/paas-k8s-devops:${version}-${env.BUILD_ID}"
}
}
container('helm') {
stage('helm deploy') {
sh "sed -i \"s/tag: prod/tag: ${version}-${env.BUILD_ID}/g\" k8s-console-chart/values.yaml"
//sh "helm upgrade --install k8s-console --namespace paas k8s-console-chart/"
sh "sed -i \"s/tag: prod/tag: ${version}-${env.BUILD_ID}/g\" devops-chart/values.yaml"
//sh "helm upgrade --install k8s-devops --namespace paas devops-chart/"
def previewTarget = "/mnt/k8s/online/${version}/charts"
if(!fileExists("${previewTarget}")) {
sh "mkdir -p ${previewTarget}"
}
sh "cp -r k8s-console-chart ${previewTarget}/"
sh "cp -r devops-chart ${previewTarget}/"
}
}
......
......@@ -28,7 +28,7 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
]) {
node(label) {
def version = "v5.1"
def version = "v6.0"
stage('checkout') {
checkout scm
......@@ -38,20 +38,18 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
container('golang') {
stage('build') {
sh 'ls -al'
sh "sed -i 's#appstore-server-url = http://appstore.dev.k2paas.com#appstore-server-url = http://apps.test.k2paas.com#g' conf/app.conf"
sh "sed -i 's#http://tenant.dev.k2paas.com#http://tenant.test.k2paas.com#g' conf/app.conf"
// 生成静态链接所有的库
sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -v -mod vendor -o k8s-console'
sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -v -mod vendor -o devops'
}
stage('copy-front') {
def dist_dir = "/mnt/k8s/online/${version}/front/k8s_console_front/dist"
def dist_dir = "/mnt/k8s/online/${version}/front/devops_front/dist"
sh "cp -r $dist_dir frontend/"
}
}
container('docker') {
//def tarName = "/mnt/k8s/online/${version}/images/paas-k8s-console_test-${env.BUILD_ID}.tar"
//def tarName = "/mnt/k8s/online/${version}/images/paas-devops_test-${env.BUILD_ID}.tar"
stage('docker-login') {
//REGISTRY_URL私有仓库地址,也可使用官方地址:docker.io
......@@ -59,33 +57,33 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
}
stage('docker-build') {
sh "docker build . -t ${params.REGISTRY_URL}/paas-test/paas-k8s-console:test-${env.BUILD_ID}"
sh "docker build . -t ${params.REGISTRY_URL}/paas-test/paas-devops:test-${env.BUILD_ID}"
}
stage('docker-push') {
sh "docker push ${params.REGISTRY_URL}/paas-test/paas-k8s-console:test-${env.BUILD_ID}"
sh "docker push ${params.REGISTRY_URL}/paas-test/paas-devops:test-${env.BUILD_ID}"
}
//stage('docker-save') {
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-k8s-console_*.tar"
// sh "docker save ${params.REGISTRY_URL}/paas-test/paas-k8s-console:test-${env.BUILD_ID} > $tarName"
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-devops_*.tar"
// sh "docker save ${params.REGISTRY_URL}/paas-test/paas-devops:test-${env.BUILD_ID} > $tarName"
//}
stage('docker-rmi') {
sh "docker rmi ${params.REGISTRY_URL}/paas-test/paas-k8s-console:test-${env.BUILD_ID}"
sh "docker rmi ${params.REGISTRY_URL}/paas-test/paas-devops:test-${env.BUILD_ID}"
}
}
container('helm') {
stage('helm deploy') {
sh "sed -i \"s/tag: test/tag: test-${env.BUILD_ID}/g\" k8s-console-chart/values-test.yaml"
sh "helm upgrade --install k8s-console --namespace paas k8s-console-chart/ -f k8s-console-chart/values-test.yaml"
sh "sed -i \"s/tag: test/tag: test-${env.BUILD_ID}/g\" devops-chart/values-test.yaml"
//sh "helm upgrade --install devops --namespace paas devops-chart/ -f devops-chart/values-test.yaml"
def previewTarget = "/mnt/k8s/online/${version}/charts"
if(!fileExists("${previewTarget}")) {
sh "mkdir -p ${previewTarget}"
}
sh "cp -r k8s-console-chart ${previewTarget}/"
sh "cp -r devops-chart ${previewTarget}/"
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment