Skip to content

setup-job.yaml

Download setup-job.yaml as it is.

deploy/kubernetes/setup-job.yaml
# Pushes and activates the package bundles the image carries
# (/usr/share/houradvantage/packages), then applies houradvantage-setup.toml
# (listeners, endpoints, settings), both through the gateway Service.
# Packages and setup are kept in Postgres, so one run sets up every pod. The
# packages go first: the endpoints name them.
#
# Running it again is safe, and the way to install the bundles of a new
# image: pushing the same bundle gives the revision it was, activating the
# active revision changes nothing, and applying again changes only what
# differs. The Job retries until the gateways answer and no pod refuses the
# activated revisions (during a rollout an old pod may), and is
# removed 10 minutes after it finishes, so the next `kubectl apply -k` runs
# it again. A Job's template cannot be changed, so while it is still there
# (a new image or a changed houradvantage-setup.toml within those 10 minutes),
# delete it first:
# kubectl -n houradvantage delete job houradvantage-setup --ignore-not-found
# kubectl apply -k .
# With GitOps, let the tool recreate it instead (uncomment below): Argo CD
# runs it as a hook after every sync, Flux replaces it when it changes.
# To run the steps by hand instead:
# kubectl -n houradvantage exec deploy/houradvantage-gateway -- env HOURADVANTAGE_ADMIN_PASSWORD='...' sh -c 'hourctl pkg push --activate /usr/share/houradvantage/packages/*.tar.gz'
# kubectl -n houradvantage exec -i deploy/houradvantage-gateway -- env HOURADVANTAGE_ADMIN_PASSWORD='...' hourctl apply /dev/stdin < houradvantage-setup.toml
# (hourctl logs in as the pod's HOURADVANTAGE_ADMIN_USERNAME.)
apiVersion: batch/v1
kind: Job
metadata:
name: houradvantage-setup
labels:
app.kubernetes.io/name: houradvantage
app.kubernetes.io/component: setup
# annotations:
# # Argo CD:
# argocd.argoproj.io/hook: PostSync
# argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
# # Flux:
# kustomize.toolkit.fluxcd.io/force: enabled
spec:
backoffLimit: 10
ttlSecondsAfterFinished: 600
template:
metadata:
labels:
app.kubernetes.io/name: houradvantage
app.kubernetes.io/component: setup
spec:
restartPolicy: OnFailure
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
seccompProfile:
type: RuntimeDefault
initContainers:
# First the packages. A shell, for the glob. It exits non-zero
# (and is run again) while a pod refuses a revision
# (`hourctl pkg show <name>` says why).
- name: packages
image: houradvantage
imagePullPolicy: IfNotPresent
command: ["sh", "-c", "exec hourctl pkg push --activate /usr/share/houradvantage/packages/*.tar.gz"]
env:
- name: HOURADVANTAGE_ADMIN_URL
value: http://houradvantage-gateway:9090
# The admin API is reached over the cluster network, which is
# private, so hourctl may send the login over plain http://.
- name: HOURADVANTAGE_INSECURE
value: "true"
- name: HOURADVANTAGE_ADMIN_USERNAME
valueFrom:
secretKeyRef: { name: houradvantage-gateway, key: admin-username }
- name: HOURADVANTAGE_ADMIN_PASSWORD_FILE
value: /run/secrets/houradvantage-setup/admin-password
resources:
requests:
cpu: 50m
memory: 32Mi
limits:
cpu: 500m
memory: 128Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
volumeMounts:
- name: password
mountPath: /run/secrets/houradvantage-setup
readOnly: true
containers:
# Then the setup.
- name: apply
image: houradvantage
imagePullPolicy: IfNotPresent
command: ["hourctl", "apply", "/etc/houradvantage/setup.toml"]
env:
- name: HOURADVANTAGE_ADMIN_URL
value: http://houradvantage-gateway:9090
# The admin API is reached over the cluster network, which is
# private, so hourctl may send the login over plain http://.
- name: HOURADVANTAGE_INSECURE
value: "true"
- name: HOURADVANTAGE_ADMIN_USERNAME
valueFrom:
secretKeyRef: { name: houradvantage-gateway, key: admin-username }
- name: HOURADVANTAGE_ADMIN_PASSWORD_FILE
value: /run/secrets/houradvantage-setup/admin-password
resources:
requests:
cpu: 50m
memory: 32Mi
limits:
cpu: 500m
memory: 128Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
volumeMounts:
- name: setup
mountPath: /etc/houradvantage
readOnly: true
- name: password
mountPath: /run/secrets/houradvantage-setup
readOnly: true
volumes:
- name: setup
configMap:
name: houradvantage-setup
- name: password
secret:
secretName: houradvantage-setup
defaultMode: 0440