Skip to content

Commit

Permalink
feat: add apollo chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
dellnoantechnp committed Jul 11, 2024
1 parent 3ac43ca commit 9a61ef7
Show file tree
Hide file tree
Showing 21 changed files with 1,390 additions and 181 deletions.
23 changes: 0 additions & 23 deletions charts/apollo-portal/.helmignore
Original file line number Diff line number Diff line change
@@ -1,23 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
27 changes: 21 additions & 6 deletions charts/apollo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
apiVersion: v2
appVersion: 2.2.0
description: A Helm chart for Apollo Config Service and Apollo Admin Service
annotations:
artifacthub.io/images: |
- name: apolloconfig/apollo-adminservice:2.2.0
image: apolloconfig/apollo-adminservice:2.2.0
artifacthub.io/links: |
- name: Chart Source
url: https://github.com/dellnoantechnp/helm-chart-xxl-job-admin/tree/main/charts
description: This Helm chart for Apollo Config Service, Apollo Admin Service and Apollo portal.
home: https://github.com/apolloconfig/apollo
icon: https://raw.githubusercontent.com/apolloconfig/apollo/master/apollo-portal/src/main/resources/static/img/logo-simple.png
maintainers:
- email: nobodyiam@gmail.com
name: nobodyiam
url: https://github.com/nobodyiam
name: apollo-service
- email: dellnoantechnp@gmail.com
name: dellnoantechnp
url: https://github.com/dellnoantechnp/helm-chart-xxl-job-admin
name: apollo
type: application
version: 0.7.0
version: 0.7.1
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
tags:
- bitnami-common
version: 2.x.x
sources:
- https://github.com/apolloconfig/apollo
501 changes: 501 additions & 0 deletions charts/apollo/init-db/apolloconfigdb.sql

Large diffs are not rendered by default.

444 changes: 444 additions & 0 deletions charts/apollo/init-db/apolloportaldb.sql

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion charts/apollo/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,34 @@ Ingress:
{{- end }}
{{- end }}


Portal url for current release:
{{- if contains "NodePort" .Values.portal.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "apollo.portal.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.portal.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 --namespace {{ .Release.Namespace }} svc -w {{ include "apollo.portal.fullName" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "apollo.portal.serviceName" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.portal.service.port }}
{{- else if contains "ClusterIP" .Values.portal.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ include "apollo.portal.fullName" . }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8070 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8070:8070
{{- end }}

{{- if .Values.portal.ingress.enabled }}

Ingress:
{{- range $host := .Values.portal.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.portal.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- end }}


Urls registered to meta service:
Config service: {{ include "apollo.configService.serviceUrl" .}}
Admin service: {{ include "apollo.adminService.serviceUrl" .}}
Admin service: {{ include "apollo.adminService.serviceUrl" .}}
122 changes: 113 additions & 9 deletions charts/apollo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,37 +1,72 @@
{{/* vim: set filetype=mustache: */}}

{{- define "apollo.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
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 "apollo.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "apollo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "apollo.service.labels" -}}
{{- if .Chart.AppVersion -}}
app.kubernetes.io/name: {{ include "apollo.name" . }}
helm.sh/chart: {{ include "apollo.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}



{{/*
Service name for configdb
*/}}
{{- define "apollo.configdb.serviceName" -}}
{{- if .Values.configdb.service.enabled -}}
{{- if .Values.configdb.service.fullNameOverride -}}
{{- .Values.configdb.service.fullNameOverride | trunc 63 | trimSuffix "-" -}}
{{- if .Values.db.configdb.service.enabled -}}
{{- if .Values.db.configdb.service.fullNameOverride -}}
{{- .Values.db.configdb.service.fullNameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Values.configdb.name | trunc 63 | trimSuffix "-" -}}
{{- printf "%s-%s" .Release.Name .Values.db.configdb.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- else -}}
{{- .Values.configdb.host -}}
{{- .Values.db.configdb.host -}}
{{- end -}}
{{- end -}}

{{/*
Service port for configdb
*/}}
{{- define "apollo.configdb.servicePort" -}}
{{- if .Values.configdb.service.enabled -}}
{{- .Values.configdb.service.port -}}
{{- if .Values.db.configdb.service.enabled -}}
{{- .Values.db.configdb.service.port -}}
{{- else -}}
{{- .Values.configdb.port -}}
{{- .Values.db.configdb.port -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -108,3 +143,72 @@ Admin service url to be accessed by apollo-portal
http://{{ include "apollo.adminService.serviceName" .}}.{{ .Release.Namespace }}:{{ .Values.adminService.service.port }}{{ .Values.adminService.config.contextPath }}
{{- end -}}
{{- end -}}




{{/*
Portal
*/}}
{{/* vim: set filetype=mustache: */}}

{{/*
Full name for apollo-portal
*/}}
{{- define "apollo.portal.fullName" -}}
{{- if .Values.fullNameOverride -}}
{{- .Values.fullNameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- if contains .Values.portal.name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Values.portal.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "apollo.portal.labels" -}}
{{- if .Chart.AppVersion -}}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- end -}}

{{/*
Service name for portal
*/}}
{{- define "apollo.portal.serviceName" -}}
{{- if .Values.portal.service.fullNameOverride -}}
{{- .Values.portal.service.fullNameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{ include "apollo.portal.fullName" .}}
{{- end -}}
{{- end -}}

{{/*
Service name for portaldb
*/}}
{{- define "apollo.portaldb.serviceName" -}}
{{- if .Values.db.portaldb.service.enabled -}}
{{- if .Values.db.portaldb.service.fullNameOverride -}}
{{- .Values.db.portaldb.service.fullNameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Values.db.portaldb.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- else -}}
{{- .Values.db.portaldb.host -}}
{{- end -}}
{{- end -}}

{{/*
Service port for portaldb
*/}}
{{- define "apollo.portaldb.servicePort" -}}
{{- if .Values.db.portaldb.service.enabled -}}
{{- .Values.db.portaldb.service.port -}}
{{- else -}}
{{- .Values.db.portaldb.port -}}
{{- end -}}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/apollo/templates/admin-service/configmap-adminservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
{{- $adminServiceFullName := include "apollo.adminService.fullName" . }}
name: {{ $adminServiceFullName }}
labels:
app.kubernetes.io/component: adminService
{{- include "apollo.service.labels" . | nindent 4 }}
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://{{include "apollo.configdb.serviceName" .}}:{{include "apollo.configdb.servicePort" .}}/{{ .Values.db.configdb.dbName }}{{ if .Values.db.configdb.connectionStringProperties }}?{{ .Values.db.configdb.connectionStringProperties }}{{ end }}
spring.datasource.username = {{ required "configdb.userName is required!" .Values.db.configdb.userName | quote }}
spring.datasource.password = {{ required "configdb.password is required!" .Values.db.configdb.password | quote }}
{{- if .Values.adminService.config.contextPath }}
server.servlet.context-path = {{ .Values.adminService.config.contextPath }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
# configmap for apollo-adminservice
kind: ConfigMap
apiVersion: v1
metadata:
{{- $adminServiceFullName := include "apollo.adminService.fullName" . }}
name: {{ $adminServiceFullName }}
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://{{include "apollo.configdb.serviceName" .}}:{{include "apollo.configdb.servicePort" .}}/{{ .Values.configdb.dbName }}{{ if .Values.configdb.connectionStringProperties }}?{{ .Values.configdb.connectionStringProperties }}{{ end }}
spring.datasource.username = {{ required "configdb.userName is required!" .Values.configdb.userName }}
spring.datasource.password = {{ required "configdb.password is required!" .Values.configdb.password }}
{{- if .Values.adminService.config.contextPath }}
server.servlet.context-path = {{ .Values.adminService.config.contextPath }}
{{- end }}
---
kind: Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
{{- $adminServiceFullName := include "apollo.adminService.fullName" . }}
name: {{ $adminServiceFullName }}
labels:
{{- include "apollo.service.labels" . | nindent 4 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/admin-service/configmap-adminservice.yaml") . | sha256sum }}
spec:
replicas: {{ .Values.adminService.replicaCount }}
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
kind: Service
apiVersion: v1
kind: Service
metadata:
name: {{ include "apollo.adminService.serviceName" . }}
labels:
{{- include "apollo.service.labels" . | nindent 4 }}
spec:
type: {{ .Values.adminService.service.type }}
{{- with .Values.adminService.service }}
type: {{ .type }}
{{- if and (eq .type "LoadBalancer") .externalTrafficPolicy }}
externalTrafficPolicy: {{ .externalTrafficPolicy }}
{{- end }}
{{- if and (eq .type "LoadBalancer") .loadBalancerIP }}
loadBalancerIP: {{ .externalTrafficPolicy }}
{{- end }}
ports:
- name: http
protocol: TCP
port: {{ .Values.adminService.service.port }}
targetPort: {{ .Values.adminService.service.targetPort }}
port: {{ .port }}
targetPort: http
{{- if and (or (eq .type "NodePort") (eq .type "LoadBalancer")) .nodePort }}
nodePort: {{ .nodePort }}
{{- end }}
selector:
app: {{ include "apollo.adminService.fullName" . }}
app: {{ include "apollo.adminService.fullName" $ }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
{{- $configServiceFullName := include "apollo.configService.fullName" . }}
name: {{ $configServiceFullName }}
labels:
app.kubernetes.io/component: configService
{{- include "apollo.service.labels" . | nindent 4 }}
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://{{include "apollo.configdb.serviceName" .}}:{{include "apollo.configdb.servicePort" .}}/{{ .Values.db.configdb.dbName }}{{ if .Values.db.configdb.connectionStringProperties }}?{{ .Values.db.configdb.connectionStringProperties }}{{ end }}
spring.datasource.username = {{ required "configdb.userName is required!" .Values.db.configdb.userName | quote }}
spring.datasource.password = {{ required "configdb.password is required!" .Values.db.configdb.password | quote }}
apollo.config-service.url = {{ include "apollo.configService.serviceUrl" .}}
apollo.admin-service.url = {{ include "apollo.adminService.serviceUrl" .}}
{{- if .Values.configService.config.contextPath }}
server.servlet.context-path = {{ .Values.configService.config.contextPath }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
# configmap for apollo-configservice
kind: ConfigMap
apiVersion: v1
metadata:
{{- $configServiceFullName := include "apollo.configService.fullName" . }}
name: {{ $configServiceFullName }}
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://{{include "apollo.configdb.serviceName" .}}:{{include "apollo.configdb.servicePort" .}}/{{ .Values.configdb.dbName }}{{ if .Values.configdb.connectionStringProperties }}?{{ .Values.configdb.connectionStringProperties }}{{ end }}
spring.datasource.username = {{ required "configdb.userName is required!" .Values.configdb.userName }}
spring.datasource.password = {{ required "configdb.password is required!" .Values.configdb.password }}
apollo.config-service.url = {{ include "apollo.configService.serviceUrl" .}}
apollo.admin-service.url = {{ include "apollo.adminService.serviceUrl" .}}
{{- if .Values.configService.config.contextPath }}
server.servlet.context-path = {{ .Values.configService.config.contextPath }}
{{- end }}
---
{{- $configServiceFullName := include "apollo.configService.fullName" . }}
kind: Deployment
apiVersion: apps/v1
metadata:
name: {{ $configServiceFullName }}
labels:
{{- include "apollo.service.labels" . | nindent 4 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config-service/configmap-configservice.yaml") . | sha256sum }}
spec:
replicas: {{ .Values.configService.replicaCount }}
selector:
Expand Down
Loading

0 comments on commit 9a61ef7

Please sign in to comment.