dynamic rendering and creation of k8s manifests/resources polled from redis streams/json
task --list: Available tasks for this project:
* build: Build the app
* build-image: Build image
* git-push: Commit & push the module
* lint: Lint code
* package: Update Chart.yaml and package archive
* push: Push to registry
* release: Build amd release to github w/ goreleaser
* run: Run app
* run-container: Run container
* run-test: Run test-producer
* tag: Commit, push & tag the module
* test: Test code
SET VAULT CONNECTION
export VAULT_ADDR=https://${VAULT_FQDN}}
export VAULT_NAMESPACE=root
# APPROLE AUTH
export VAULT_AUTH_METHOD=approle
export VAULT_ROLE_ID=${VAULT_ROLE_ID}
export VAULT_SECRET_ID=${VAULT_SECRET_ID}
# TOKEN AUTH
export VAULT_AUTH_METHOD=token #default
export VAULT_TOKEN=${VAULT_TOKEN}
RENDER/APPLY
helmfile template --environment labul-pve-dev
helmfile sync --environment labul-pve-dev
DEPLOYMENT
helm pull oci://eu.gcr.io/stuttgart-things/stagetime-creator --version v0.1.44
cat <<EOF > stageTime-creator.yaml
---
secrets:
redis-connection:
name: redis-connection
labels:
app: stagetime-server
dataType: stringData
secretKVs:
REDIS_SERVER: redis-stack-deployment-headless.redis-stack.svc.cluster.local
REDIS_PORT: 6379
REDIS_PASSWORD: <PASSWORD>
EOF
helm upgrade --install stagetime-creator oci://eu.gcr.io/stuttgart-things/stagetime-creator --version v0.1.44 --values stageTime-creator.yaml -n stagetime-creator --create-namespace
CHECK REDIS DATA w/ CLI
# INSTALL REDIS-CLI
sudo apt-get update
sudo apt-get install redis
# SHELL #1
kubectl -n stagetime port-forward redis-stack-node-0 28015:6379 -n stagetime-redis
# SHELL #2
redis-cli -h 127.0.0.1 -p 28015 -a ${PASSWORD}
# CHECK ALL REDIS KEYS
KEYS *
# READ STREAM
XREAD COUNT 2 STREAMS stagetime-revisionruns writers 0-0 0-0
# DELETE STREAM
DEL stagetime-revisionruns
START CONSUMER
export KUBECONFIG=~/.kube/dev11
export TEMPLATE_PATH=~/projects/go/src/github/stageTime-creator/tests
export TEMPLATE_NAME=job-template.yaml
export REDIS_STREAM=stagetime:test
export REDIS_PASSWORD=<SET-ME>
export REDIS_SERVER=redis-pve.labul.sva.de
export REDIS_PORT=6379
task run
START TEST PRODUCING (EXTERNAL REDIS)
# kubectl -n stagetime-redis port-forward redis-stagetime-deployment-node-0 28015:6379
task run-test
START TEST PRODUCING (REDIS INSIDE CLUSTER)
kubectl -n <REDIS-NS> port-forward redis-stagetime-deployment-node-0 <HOST-PORT>:<CONTAINER-PORT>
# kubectl -n stagetime-redis port-forward redis-stagetime-deployment-node-0 28015:6379
export REDIS_STREAM=stagetime-revisionruns
export REDIS_PASSWORD=<SETME>
export REDIS_SERVER=127.0.0.1
export REDIS_PORT=28015 # HOST-PORT
go run tests/test-json-set.go
VERIFY REDIS
redis-cli -h <REDIS_SERVER>-p <HOST-PORT> -a <SETME>
# redis-cli -h 127.0.0.1 -p 28015 -a test
KEYS *
# GET VALUE
GET <KEYNAME>
# GET STREAM
XREAD COUNT 2 STREAMS <STREAM-NAME> writers 0-0 0-0
APACHE 2.0
Copyright 2023 patrick hermann.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Patrick Hermann, stuttgart-things 06/2023