Skip to content

Commit

Permalink
[TASk] add shenyu-admin ingress and hpa (#27)
Browse files Browse the repository at this point in the history
* hpa done

* add ingress and hpa

* add shenyu-admin ingress and hpa

* fix style

* fix style

* change default false
  • Loading branch information
misaya295 authored Dec 2, 2022
1 parent 7adae20 commit ec01b0a
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 24 deletions.
2 changes: 1 addition & 1 deletion charts/shenyu/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: shenyu
description: Helm Chart for deploying Apache ShenYu in Kubernetes
type: application
version: 0.5.2
version: 0.5.3
appVersion: "2.5.0"
icon: https://shenyu.apache.org/img/logo.png
maintainers:
Expand Down
32 changes: 32 additions & 0 deletions charts/shenyu/templates/shenyu-admin-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.admin.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-admin
labels:
"app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
"app.kubernetes.io/managed-by": "{{ .Release.Service }}"
"app.kubernetes.io/component": "shenyu-admin"
"app.kubernetes.io/instance": "{{ .Release.Name }}"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "common.names.fullname" . }}-admin
minReplicas: {{ .Values.admin.autoscaling.minReplicas }}
maxReplicas: {{ .Values.admin.autoscaling.maxReplicas }}
metrics:
{{- if .Values.admin.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.admin.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.admin.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.admin.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
64 changes: 64 additions & 0 deletions charts/shenyu/templates/shenyu-admin-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- if .Values.admin.ingress.enabled -}}
{{- $fullName := include "common.names.fullname" . -}}
{{- $svcPort := .Values.admin.service.port -}}
{{- if and .Values.admin.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.admin.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.admin.ingress.annotations "kubernetes.io/ingress.class" .Values.admin.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}-admin
labels:
"app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
"app.kubernetes.io/managed-by": "{{ .Release.Service }}"
"app.kubernetes.io/component": "shenyu-admin"
"app.kubernetes.io/instance": "{{ .Release.Name }}"
{{- with .Values.admin.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.admin.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.admin.ingress.className }}
{{- end }}
{{- if .Values.admin.ingress.tls }}
tls:
{{- range .Values.admin.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.admin.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}-admin
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}-admin
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 3 additions & 3 deletions charts/shenyu/templates/shenyu-admin-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
type: NodePort
ports:
- protocol: TCP
port: 9095
targetPort: 9095
nodePort: {{ .Values.admin.nodePort }}
port: {{ .Values.admin.service.port }}
targetPort: {{ .Values.admin.service.targetPod }}
nodePort: {{ .Values.admin.service.nodePort }}
{{- end -}}
6 changes: 3 additions & 3 deletions charts/shenyu/templates/shenyu-bootstrap-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
type: NodePort
ports:
- protocol: TCP
port: 9195
targetPort: 9195
nodePort: {{ .Values.bootstrap.nodePort }}
port: {{ .Values.bootstrap.service.port }}
targetPort: {{ .Values.bootstrap.service.targetPod }}
nodePort: {{ .Values.bootstrap.service.nodePort }}
{{- end -}}
61 changes: 44 additions & 17 deletions charts/shenyu/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,62 @@ admin:
# replicas of admin, K8s will load balance the requests
replicas: 1
image: apache/shenyu-admin
# if you want to change "admin service port", please edit here
nodePort: 31095
service:
port: 9095
targetPod: 9095
# if you want to change "admin service port", please edit here
nodePort: 31095
# jvm options for admin
javaOpts: ""
# K8s resources quota for admin
resources:
# requests:
# cpu: 100m
# memory: 512Mi
# limits:
# cpu: 1000m
# memory: 1024Mi
# requests:
# cpu: 100m
# memory: 512Mi
# limits:
# cpu: 1000m
# memory: 1024Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 75
targetMemoryUtilizationPercentage: 75
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: shenyu-admin.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
bootstrap:
enabled: true
# replicas of bootstrap, K8s will load balance the requests
replicas: 2
image: apache/shenyu-bootstrap
# if you want to change "bootstrap service port", please edit here
nodePort: 31195
service:
port: 9195
targetPod: 9195
# if you want to change "bootstrap service port", please edit here
nodePort: 31195
# jvm options for bootstrap
javaOpts: ""
# K8s resources quota for bootstrap
resources:
# requests:
# cpu: 100m
# memory: 512Mi
# limits:
# cpu: 1000m
# memory: 1024Mi
# requests:
# cpu: 100m
# memory: 512Mi
# limits:
# cpu: 1000m
# memory: 1024Mi

#################################################
# datasource config of shenyu-admin #
Expand Down Expand Up @@ -236,7 +263,7 @@ applicationConfig:
allowedMethods: "*"
# the same of Access-Control-Allow-Origin: "*"
allowedAnyOrigin: true
# allowedOrigin:
# allowedOrigin:
# format : schema://prefix spacer domain
# Access-Control-Allow-Origin: "http://a.apache.org,http://b.apache.org"
# spacer: "."
Expand Down

0 comments on commit ec01b0a

Please sign in to comment.