Skip to content

Commit

Permalink
doing it the manual way
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Afro committed Jan 14, 2025
1 parent 01b2d1f commit 0c98160
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 134 deletions.
60 changes: 60 additions & 0 deletions ansible/roles/dof_rabbitmq/enable-feature-flags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -euo pipefail

KUBECONFIG_OPTION=""
NAMESPACE=""
COMPONENT_NAME="rabbitmq"
CONTAINER_NAME="rabbitmq"
COMMAND="cat /etc/issue"

while [[ $# -gt 0 ]]; do
case $1 in
--kubeconfig)
KUBECONFIG_OPTION="--kubeconfig=$2"
shift 2
;;
--namespace)
NAMESPACE=$2
shift 2
;;
--component-name)
COMPONENT_NAME=$2
shift 2
;;
--container-name)
CONTAINER_NAME=$2
shift 2
;;
--command)
COMMAND=$2
shift 2
;;
*)
echo "Unknown argument: $1"
echo "Usage: $0 --namespace <namespace> [--kubeconfig <path>] [--component-name <name>] [--container-name <name>] [--command <command>]"
exit 1
;;
esac
done

if [[ -z "$NAMESPACE" ]]; then
echo "Error: --namespace is required"
echo "Usage: $0 --namespace <namespace> [--kubeconfig <path>] [--component-name <name>] [--container-name <name>] [--command <command>]"
exit 1
fi

PODS=$(kubectl $KUBECONFIG_OPTION get pods -n "$NAMESPACE" -l "app.kubernetes.io/component=$COMPONENT_NAME" -o jsonpath='{.items[*].metadata.name}')

if [[ -z "$PODS" ]]; then
echo "No pods found matching app.kubernetes.io/component=$COMPONENT_NAME in namespace $NAMESPACE"
exit 1
fi

for POD in $PODS; do
echo "Executing command in pod: $POD"
kubectl $KUBECONFIG_OPTION exec -n "$NAMESPACE" -c "$CONTAINER_NAME" "$POD" -- $COMMAND || {
echo "Failed to execute command in pod: $POD" >&2
exit 1
}
done
27 changes: 0 additions & 27 deletions ansible/roles/dof_rabbitmq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,3 @@
tags:
- prometheus


- name: Enable Feature Flags ConfigMap
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: enable-feature-flags-job-configmap.yaml.j2
tags:
- configmap

- name: Delete existing feature flags job if it exists
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
api_version: batch/v1
kind: Job
name: enable-feature-flags-job
state: absent
tags:
- job

- name: Create the Enable Feature Flags Job
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: enable-feature-flags-job.yaml.j2
tags:
- job

This file was deleted.

This file was deleted.

0 comments on commit 0c98160

Please sign in to comment.