I'm currently running through the secure deployment guide for CockroachDB on Kubernetes and while it works exactly as expected, but I'm searching for ways to streamline/automate the deployment. I'm using Configs
to deploy, and I would honestly just like to be able to automate the final step (after kubectl create -f cockroachdb-statefulset.yaml
). I've been searching around for guides on streamlining deployments, but I haven't come up with much. Is there a way to complete the following after the config application:
kubectl exec -it cockroachdb-0 \
-- /cockroach/cockroach init \
--certs-dir=/cockroach/cockroach-certs
Perhaps as part of an initContainer
in the cockroachdb-statefulset.yaml
config?
I'm also looking for a way to automate the creation of a db/user account, so any insight there would be greatly appreciated.
Thanks!
take a look on kubernetes jos
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
You can integrate this yaml within your deployment, but I do think you need write some wrapper script to confirm the cockroach service is up and health first.
so the job's command coule be:
while true;
do
if `command to check health`; then
# run kubernetes exec
exit
else
sleep 5
fi
done