Skip to content

Commit

Permalink
fix: added support for secret when pulling from Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
lstoppa committed Mar 8, 2021
1 parent 86fd5f0 commit cc4d9be
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ For testing we simply need to go to the sc4snmp/poller and run:
./create_deployment.sh

You'll be asked to provide your personal auth token from github and that's all.


37 changes: 37 additions & 0 deletions deploy/sc4snmp/poller/create_deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,55 @@ kubernetes_poller_deploy_or_update_config() {
kubectl get configmap "${kubernetes_configmap_name}" -o yaml
}

kubernetes_create_or_replace_docker_secret() {
server=$1
username=$2
authentication_token=$3
email=$4
secret_name=$5

kubectl delete secret "${secret_name}"
kubectl create secret docker-registry "${secret_name}" \
--docker-server="${server}" \
--docker-username="${username}" \
--docker-password="${authentication_token}" \
--docker-email="${email}"
}

clean_up() {
for temporary_file in "$@"; do
rm -rf "${temporary_file}"
done
}

undeploy_poller() {
rabbitmq_deployment="deployment.apps/$(yq -r .metadata.name rq-deployment.yaml)"
echo "Removing deployment for ${rabbitmq_deployment}"
kubectl delete "${rabbitmq_deployment}"

rabbitmq_service="service/$(yq -r .metadata.name rq-service.yaml)"
echo "Removing service ${rabbitmq_service}"
kubectl delete "${rabbitmq_service}"
}

kubernetes_deploy_rabbitmq() {
kubectl create -f rq-deployment.yaml
kubectl create -f rq-service.yaml
}

# -----------------------------------------------------------------------------
# MAIN
# -----------------------------------------------------------------------------
github_username="${USER}"
github_email="${github_username}@splunk.com"
echo "Please type your person access github token:"
read -r token
poller_config_file=$(download_poller_config_file "${token}")
kubernetes_poller_deploy_or_update_config "${poller_config_file}" "${KUBERNETES_POLLER_CONFIG_MAP_NAME}"
# TODO: try to get the secret name with yq directly from poller-deployment.yaml. For now I am
# getting a syntax error when trying to access a list, not sure why.
kubernetes_create_or_replace_docker_secret "https://ghcr.io/v2/splunk" ${github_username} ${token} ${github_email} "regcred"
kubernetes_deploy_rabbitmq

clean_up "${poller_config_file}"
#undeploy_poller
7 changes: 5 additions & 2 deletions deploy/sc4snmp/poller/poller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ spec:
- name: sc4-snmp-poller
# image: luca/test-poller-3
# TODO: not sure what image I should put it for now.
image: ghcr.io/splunk/splunk-connect-for-snmp-poller
imagePullPolicy: Never
image: ghcr.io/splunk/splunk-connect-for-snmp-poller:a6d7d755e23c1674f28de9a6a3e263fec1648632
#imagePullPolicy: Never
ports:
- containerPort: 2162
env:
- name: CELERY_BROKER_URL
value: amqp://guest@$(RABBITMQ_SERVICE_SERVICE_HOST):$(RABBITMQ_SERVICE_SERVICE_PORT)//
- name: POLLER_EXECUTION_MODE
value: poller
imagePullSecrets:
- name: regcred




0 comments on commit cc4d9be

Please sign in to comment.