Skip to content

Commit

Permalink
Introduce replicas options
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
  • Loading branch information
kvaps committed Apr 26, 2024
1 parent a956713 commit 7cd7de7
Show file tree
Hide file tree
Showing 37 changed files with 130 additions and 77 deletions.
25 changes: 22 additions & 3 deletions hack/gen_versions_map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,28 @@ miss_map=$(echo "$new_map" | awk 'NR==FNR { new_map[$1 " " $2] = $3; next } { if
resolved_miss_map=$(
echo "$miss_map" | while read chart version commit; do
if [ "$commit" = HEAD ]; then
line=$(git show HEAD:"./$chart/Chart.yaml" | awk '/^version:/ {print NR; exit}')
change_commit=$(git --no-pager blame -L"$line",+1 HEAD -- "$chart/Chart.yaml" | awk '{print $1}')
commit=$(git describe --always "$change_commit~1")
line=$(awk '/^version:/ {print NR; exit}' "./$chart/Chart.yaml")
change_commit=$(git --no-pager blame -L"$line",+1 -- "$chart/Chart.yaml" | awk '{print $1}')
if [ "$change_commit" = "00000000" ]; then
# Not commited yet, use previus commit
line=$(git show HEAD:"./$chart/Chart.yaml" | awk '/^version:/ {print NR; exit}')
commit=$(git --no-pager blame -L"$line",+1 HEAD -- "$chart/Chart.yaml" | awk '{print $1}')
if [ $(echo $commit | cut -c1) = "^" ]; then
# Previus commit not exists
commit=$(echo $commit | cut -c2-)
fi
else
# Commited, but version_map wasn't updated
line=$(git show HEAD:"./$chart/Chart.yaml" | awk '/^version:/ {print NR; exit}')
change_commit=$(git --no-pager blame -L"$line",+1 HEAD -- "$chart/Chart.yaml" | awk '{print $1}')
if [ $(echo $change_commit | cut -c1) = "^" ]; then
# Previus commit not exists
commit=$(echo $change_commit | cut -c2-)
else
commit=$(git describe --always "$change_commit~1")
fi
fi
fi
echo "$chart $version $commit"
done
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/clickhouse/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "24.3.0"
4 changes: 2 additions & 2 deletions packages/apps/clickhouse/templates/clickhouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spec:
clusters:
- name: "clickhouse"
layout:
shardsCount: 1
replicasCount: 2
shardsCount: {{ .Values.shards }}
replicasCount: {{ .Values.replicas }}
{{- with .Values.size }}
templates:
volumeClaimTemplates:
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/clickhouse/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
size: 10Gi
shards: 1
replicas: 2

users:
user1:
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/http-cache/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "1.25.3"
2 changes: 1 addition & 1 deletion packages/apps/http-cache/templates/haproxy/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ data:
option redispatch 1
default-server observe layer7 error-limit 10 on-error mark-down
{{- range $i, $e := until (int $.Values.replicas) }}
{{- range $i, $e := until (int $.Values.nginx.replicas) }}
server cache{{ $i }} {{ $.Release.Name }}-nginx-cache-{{ $i }}:80 check
{{- end }}
{{- range $i, $e := $.Values.endpoints }}
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/http-cache/templates/haproxy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: 2
replicas: {{ .Values.haproxy.replicas }}
selector:
matchLabels:
app: {{ .Release.Name }}-haproxy
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/http-cache/templates/nginx/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
selector:
matchLabels:
app: {{ $.Release.Name }}-nginx-cache
{{- range $i := until 3 }}
{{- range $i := until (int $.Values.nginx.replicas) }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down
6 changes: 6 additions & 0 deletions packages/apps/http-cache/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
external: false

haproxy:
replicas: 2
nginx:
replicas: 2

size: 10Gi
endpoints:
- 10.100.3.1:80
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/kafka/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "3.7.0"
4 changes: 2 additions & 2 deletions packages/apps/kafka/templates/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
kafka:
replicas: 3
replicas: {{ .Values.replicas }}
listeners:
- name: plain
port: 9092
Expand Down Expand Up @@ -41,7 +41,7 @@ spec:
{{- end }}
deleteClaim: true
zookeeper:
replicas: 3
replicas: {{ .Values.replicas }}
storage:
type: persistent-claim
{{- with .Values.zookeeper.size }}
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/kafka/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
external: false
kafka:
size: 10Gi
replicas: 3
zookeeper:
size: 5Gi
replicas: 3

topics:
- name: Results
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/kubernetes/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "1.19.0"
42 changes: 21 additions & 21 deletions packages/apps/kubernetes/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ metadata:
cluster.x-k8s.io/managed-by: kamaji
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
{{- range $groupName, $group := .Values.nodeGroups }}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: {{ .Release.Name }}-md-0
namespace: {{ .Release.Namespace }}
name: {{ $.Release.Name }}-{{ $groupName }}
namespace: {{ $.Release.Namespace }}
spec:
template:
spec:
Expand All @@ -78,32 +79,32 @@ spec:
kubeletExtraArgs: {}
discovery:
bootstrapToken:
apiServerEndpoint: {{ .Release.Name }}.{{ .Release.Namespace }}.svc:6443
apiServerEndpoint: {{ $.Release.Name }}.{{ $.Release.Namespace }}.svc:6443
initConfiguration:
skipPhases:
- addon/kube-proxy
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: KubevirtMachineTemplate
metadata:
name: {{ .Release.Name }}-md-0
namespace: {{ .Release.Namespace }}
name: {{ $.Release.Name }}-{{ $groupName }}
namespace: {{ $.Release.Namespace }}
spec:
template:
spec:
virtualMachineBootstrapCheck:
checkStrategy: ssh
virtualMachineTemplate:
metadata:
namespace: {{ .Release.Namespace }}
namespace: {{ $.Release.Namespace }}
spec:
runStrategy: Always
template:
spec:
domain:
cpu:
threads: 1
cores: 2
cores: {{ $group.resources.cpu }}
sockets: 1
devices:
disks:
Expand All @@ -112,7 +113,7 @@ spec:
name: containervolume
networkInterfaceMultiqueue: true
memory:
guest: 1024Mi
guest: {{ $group.resources.memory }}
evictionStrategy: External
volumes:
- containerDisk:
Expand All @@ -122,29 +123,28 @@ spec:
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ .Release.Name }}-md-0
namespace: {{ .Release.Namespace }}
name: {{ $.Release.Name }}-{{ $groupName }}
namespace: {{ $.Release.Namespace }}
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "2"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "0"
capacity.cluster-autoscaler.kubernetes.io/memory: "1024Mi"
capacity.cluster-autoscaler.kubernetes.io/cpu: "2"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "{{ $group.minReplicas }}"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "{{ $group.maxReplicas }}"
capacity.cluster-autoscaler.kubernetes.io/memory: "{{ $group.resources.memory }}"
capacity.cluster-autoscaler.kubernetes.io/cpu: "{{ $group.resources.cpu }}"
spec:
clusterName: {{ .Release.Name }}
selector:
matchLabels: null
clusterName: {{ $.Release.Name }}
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Release.Name }}-md-0
name: {{ $.Release.Name }}-{{ $groupName }}
namespace: default
clusterName: {{ .Release.Name }}
clusterName: {{ $.Release.Name }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: KubevirtMachineTemplate
name: {{ .Release.Name }}-md-0
name: {{ $.Release.Name }}-{{ $groupName }}
namespace: default
version: v1.23.10
version: v1.29.0
{{- end }}
11 changes: 0 additions & 11 deletions packages/apps/kubernetes/values.schema.json

This file was deleted.

9 changes: 9 additions & 0 deletions packages/apps/kubernetes/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
host: ""
controlPlane:
replicas: 2
nodeGroups:
md0:
minReplicas: 0
maxReplicas: 10
resources:
cpu: 2
memory: 1024Mi
4 changes: 2 additions & 2 deletions packages/apps/mysql/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.3.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "11.0.2"
4 changes: 3 additions & 1 deletion packages/apps/mysql/templates/mariadb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:

port: 3306

replicas: 2
replicas: {{ .Values.replicas }}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -28,11 +28,13 @@ spec:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"

{{- if gt (int .Values.replicas) 1 }}
replication:
enabled: true
#primary:
# podIndex: 0
# automaticFailover: true
{{- end }}

metrics:
enabled: true
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/mysql/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
external: false
size: 10Gi

replicas: 2

users:
root:
password: strongpassword
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/postgres/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "16.2"
2 changes: 1 addition & 1 deletion packages/apps/postgres/templates/db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Cluster
metadata:
name: {{ .Release.Name }}
spec:
instances: 2
instances: {{ .Values.replicas }}
enableSuperuserAccess: true

postgresql:
Expand Down
1 change: 1 addition & 0 deletions packages/apps/postgres/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
external: false
size: 10Gi
replicas: 2

users:
user1:
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/rabbitmq/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "3.12.2"
2 changes: 1 addition & 1 deletion packages/apps/rabbitmq/templates/rabbitmq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: 3
replicas: {{ .Values.replicas }}
{{- if .Values.external }}
service:
type: LoadBalancer
Expand Down
4 changes: 4 additions & 0 deletions packages/apps/rabbitmq/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"external": {
"type": "boolean",
"title": "Enable external Access"
},
"replicas": {
"type": "integer",
"title": "Replicas"
}
}
}
1 change: 1 addition & 0 deletions packages/apps/rabbitmq/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
replicas: 3
external: false
Loading

0 comments on commit 7cd7de7

Please sign in to comment.