-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datadir automatic sync #126
base: main
Are you sure you want to change the base?
Changes from all commits
c84ac7e
8d5755c
3bf6369
93f5319
9645ede
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{{- $webapp := .Values.georchestra.datadirsync -}} | ||
{{- if $webapp.enabled -}} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "georchestra.fullname" . }}-datadirsync | ||
labels: | ||
{{- include "georchestra.labels" . | nindent 4 }} | ||
app.kubernetes.io/component: {{ include "georchestra.fullname" . }}-datadirsync | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: {{ include "georchestra.fullname" . }}-datadirsync | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ include "georchestra.fullname" . }}-datadirsync | ||
spec: | ||
serviceAccountName: {{ include "georchestra.fullname" . }}-datadirsync-serviceaccount | ||
initContainers: | ||
- name: init-permissions | ||
image: busybox | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
echo "Setting up SSH key..." | ||
if cp /tmp-ssh/id_rsa /tmp/git-rollout-operator/id_rsa; then | ||
echo "SSH key copied successfully" | ||
else | ||
echo "Copy failed" | ||
fi | ||
if chown 1001:1001 /tmp/git-rollout-operator/id_rsa && chmod 600 /tmp/git-rollout-operator/id_rsa; then | ||
echo "SSH key permissions and ownership set successfully" | ||
else | ||
echo "Failed to set permissions or ownership" | ||
fi | ||
volumeMounts: | ||
- name: ssh-key-volume | ||
mountPath: /tmp-ssh | ||
- name: git-rollout-operator-volume | ||
mountPath: /tmp/git-rollout-operator | ||
containers: | ||
- name: operator | ||
image: {{ $webapp.image }} | ||
env: | ||
- name: GIT_REPO_URL | ||
value: "{{ .Values.georchestra.datadir.git.url }}" | ||
- name: GIT_BRANCH | ||
value: "{{ .Values.georchestra.datadir.git.ref }}" | ||
- name: POLL_INTERVAL | ||
value: "{{ $webapp.pollInterval }}" | ||
- name: ROLLOUT_DEPLOYMENTS | ||
value: | | ||
{{ $prefix := include "georchestra.fullname" . -}} | ||
{{ $suffixes := $webapp.deploymentSuffixNameList -}} | ||
{{ $deployments := list -}} | ||
{{- range $suffix := $suffixes }} | ||
{{ $deployments = append $deployments (printf "%s-%s" $prefix $suffix) }} | ||
{{- end -}} | ||
{{- join ", " $deployments }} | ||
- name: ROLLOUT_NAMESPACE | ||
value: "{{ .Release.Namespace }}" | ||
{{- if and .Values.gitCredentials.username .Values.gitCredentials.token }} | ||
- name: GIT_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ $webapp.gitCredentials.secretName }}" | ||
key: "{{ $webapp.gitCredentials.usernameKey }}" | ||
- name: GIT_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ $webapp.gitCredentials.secretName }}" | ||
key: "{{ $webapp.gitCredentials.tokenKey }}" | ||
{{- end }} | ||
{{- if .Values.gitCredentials.ssh }} | ||
- name: GIT_SSH_COMMAND | ||
value: ssh -i /tmp/git-rollout-operator/id_rsa -o "IdentitiesOnly=yes" -o "StrictHostKeyChecking=no" | ||
volumeMounts: | ||
- name: ssh-key-volume | ||
mountPath: /tmp-ssh/id_rsa | ||
subPath: id_rsa | ||
- name: git-rollout-operator-volume | ||
mountPath: /tmp/git-rollout-operator | ||
{{- end }} | ||
volumes: | ||
- name: ssh-key-volume | ||
secret: | ||
secretName: {{ include "georchestra.fullname" . }}-{{ $webapp.gitCredentials.secretSuffixName }} | ||
items: | ||
- key: {{ $webapp.gitCredentials.sshKey }} | ||
path: id_rsa | ||
- name: git-rollout-operator-volume | ||
emptyDir: {} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- $webapp := .Values.georchestra.datadirsync -}} | ||
{{- if $webapp.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
namespace: {{ .Release.Namespace }} | ||
name: {{ include "georchestra.fullname" . }}-datadirsync-role | ||
rules: | ||
- apiGroups: ["apps"] | ||
resources: ["pods", "deployments"] | ||
verbs: ["get", "list", "patch", "update"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we limit ourselves to just: |
||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{- $webapp := .Values.georchestra.datadirsync -}} | ||
{{- if $webapp.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "georchestra.fullname" . }}-datadirsync-rolebinding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "georchestra.fullname" . }}-datadirsync-serviceaccount | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
kind: Role | ||
name: {{ include "georchestra.fullname" . }}-datadirsync-role | ||
apiGroup: rbac.authorization.k8s.io | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- $webapp := .Values.georchestra.datadirsync -}} | ||
{{- if $webapp.enabled -}} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "georchestra.fullname" . }}-datadirsync-credentials | ||
type: Opaque | ||
data: | ||
username: {{ .Values.gitCredentials.username | b64enc }} | ||
token: {{ .Values.gitCredentials.token | b64enc }} | ||
ssh: {{ .Values.gitCredentials.ssh | b64enc }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{{- $webapp := .Values.georchestra.datadirsync -}} | ||
{{- if $webapp.enabled -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "georchestra.fullname" . }}-datadirsync-serviceaccount | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,6 +263,19 @@ georchestra: | |
# relay_username: aaaa | ||
# relay_password: aaaa | ||
extra_environment: [] | ||
datadirsync: | ||
enabled: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put the datadir sync disabled by default. |
||
image: jemacchi/simple-git-rollout-operator:1.3.1 # TODO: image should be in context of c2c dockerhub account (?) | ||
pollInterval: 10 | ||
deploymentSuffixNameList: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One component is sufficient for the example. You can just limit to |
||
- geoserver | ||
- mapstore | ||
- header | ||
gitCredentials: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain what's the diff here with the other gitCredentials section in the YAML? |
||
secretSuffixName: datadirsync-credentials | ||
usernameKey: username | ||
tokenKey: token | ||
sshKey: ssh | ||
|
||
fqdn: "georchestra-127-0-1-1.traefik.me" | ||
|
||
|
@@ -393,6 +406,11 @@ rabbitmq: | |
# storage_class_name: default | ||
# size: 1Gi | ||
|
||
gitCredentials: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we reuse the values from here: https://github.com/georchestra/helm-georchestra/pull/126/files#diff-8377b3e3740a3fcd9f682e5fb55425f2fdbece1791854b9e5013e7f1a5e60e7eL213-L215? |
||
username: "" # To be provided during helm install | ||
token: "" # To be provided during helm install | ||
ssh: "" # To be provided during helm install | ||
|
||
# Allow to override /etc/hosts for ALL apps | ||
# https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ | ||
hostAliases: [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to limit the roles to the deployments listed in
deploymentSuffixNameList
?According to stackoverflow you can limit the access to certain deployments using
resourceNames
: https://stackoverflow.com/a/68980720