Skip to content
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

Reset mount filesystem #137

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 112 additions & 5 deletions charts/templates/server-repository/reset-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,77 @@ spec:
backoffLimit: 0
template:
spec:
serviceAccountName: {{ template "sourcify.serverRepository.serviceAccountName" . }}
serviceAccountName: {{ printf "%s-%s" .Chart.Name "prvw-reset-sa" | trimSuffix "-"| trunc 52 }}
restartPolicy: Never
containers:
- name: reset
image: "{{ .Values.reset.image.repository }}:{{ .Values.reset.image.tag }}"
imagePullPolicy: {{ .Values.reset.image.pullPolicy }}
command:
- /bin/sh
- /bin/bash
- -c
- wget https://raw.githubusercontent.com/hashgraph/hedera-sourcify/main/scripts/hedera-reset.sh ; chmod +x hedera-reset.sh ; ./hedera-reset.sh previewnet
- POD=$(kubectl get pods -l app.kubernetes.io/name=sourcify-server-repository -n sourcify | tail -1 | awk '{print $1}'); kubectl exec -it -n sourcify $POD -- ./hedera-reset-docker.sh previewnet
{{- end }}

---
{{- if .Values.reset.previewnet_reset.enabled }}
rustyShacklefurd marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ printf "%s-%s" .Chart.Name "prvw-reset-sa" | trimSuffix "-"| trunc 52 }}
labels:
{{- include "sourcify.labels" . | nindent 4 }}
{{- with .Values.serverRepository.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

---
{{- if .Values.reset.previewnet_reset.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ printf "%s-%s" .Chart.Name "prvw-reset-role" | trimSuffix "-"| trunc 52 }}
labels:
{{- include "sourcify.labels" . | nindent 4 }}
{{- with .Values.serverRepository.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
{{- end }}

---
{{- if .Values.reset.previewnet_reset.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ printf "%s-%s" .Chart.Name "prvw-reset-rolebinding" | trimSuffix "-"| trunc 52 }}
labels:
{{- include "sourcify.labels" . | nindent 4 }}
{{- with .Values.serverRepository.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ printf "%s-%s" .Chart.Name "prvw-reset-role" | trimSuffix "-"| trunc 52 }}
subjects:
- kind: ServiceAccount
name: {{ printf "%s-%s" .Chart.Name "prvw-reset-sa" | trimSuffix "-"| trunc 52 }}
namespace: {{ .Release.Namespace }}
{{- end }}

---
# Testnet reset job
{{- if .Values.reset.testnet_reset.enabled }}
apiVersion: batch/v1
kind: CronJob
Expand All @@ -39,7 +97,7 @@ spec:
backoffLimit: 0
template:
spec:
serviceAccountName: {{ template "sourcify.serverRepository.serviceAccountName" . }}
serviceAccountName: {{ printf "%s-%s" .Chart.Name "tsnt-reset-sa" | trimSuffix "-"| trunc 52 }}
restartPolicy: Never
containers:
- name: reset
Expand All @@ -48,5 +106,54 @@ spec:
command:
- /bin/sh
- -c
- wget https://raw.githubusercontent.com/hashgraph/hedera-sourcify/main/scripts/hedera-reset.sh ; chmod +x hedera-reset.sh ; ./hedera-reset.sh testnet
- POD=$(kubectl get pods -l app.kubernetes.io/name=sourcify-server-repository -n sourcify | tail -1 | awk '{print $1}'); kubectl exec -it -n sourcify $POD -- ./hedera-reset-docker.sh testnet
---
# This job requires a special service account with specific permissions to accomplish this task
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ printf "%s-%s" .Chart.Name "tsnt-reset-sa" | trimSuffix "-"| trunc 52 }}
labels:
{{- include "sourcify.labels" . | nindent 4 }}
{{- with .Values.serverRepository.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ printf "%s-%s" .Chart.Name "tsnt-reset-role" | trimSuffix "-"| trunc 52 }}
labels:
{{- include "sourcify.labels" . | nindent 4 }}
{{- with .Values.serverRepository.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ printf "%s-%s" .Chart.Name "tsnt-reset-role-binding" | trimSuffix "-"| trunc 52 }}
labels:
{{- include "sourcify.labels" . | nindent 4 }}
{{- with .Values.serverRepository.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ printf "%s-%s" .Chart.Name "tsnt-reset-role" | trimSuffix "-"| trunc 52 }}
subjects:
- kind: ServiceAccount
name: {{ printf "%s-%s" .Chart.Name "tsnt-reset-sa" | trimSuffix "-"| trunc 52 }}
namespace: {{ .Release.Namespace }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ reset:
enabled: false
## Set default immage repository, tag, and pull policy
image:
repository: "apline/curl"
tag: "8.4.0"
repository: "bitnami/kubectl"
tag: "1.28.7"
pullPolicy: "IfNotPresent"

Loading