Skip to content

Commit

Permalink
NODE-5888 use user token with group name
Browse files Browse the repository at this point in the history
  • Loading branch information
dmironov-wallarm committed Dec 3, 2024
1 parent c64d6cf commit e527899
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
SKIP_IMAGE_CREATION: true
DOCKERHUB_USER: ${{ steps.secrets.outputs.user }}
DOCKERHUB_PASSWORD: ${{ steps.secrets.outputs.password }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.user_token }}
WALLARM_API_HOST: ${{ steps.secrets.outputs.api_host }}
WALLARM_API_PRESET: ${{ steps.secrets.outputs.api_preset }}
USER_TOKEN: ${{ steps.secrets.outputs.user_token }}
Expand Down Expand Up @@ -261,7 +261,7 @@ jobs:
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.user_token }}
CT_MODE: ${{ matrix.method }}
DOCKERHUB_USER: ${{ steps.secrets.outputs.DOCKERHUB_USER }}
DOCKERHUB_PASSWORD: ${{ steps.secrets.outputs.DOCKERHUB_PASSWORD }}
Expand Down Expand Up @@ -357,6 +357,7 @@ jobs:
secrets: |
kv-gitlab-ci/data/github/ingress api_token ;
kv-gitlab-ci/data/github/ingress api_host ;
kv-gitlab-ci/data/github/ingress user_token ;
kv-gitlab-ci/data/github/shared/dockerhub-creds user | DOCKERHUB_USER ;
kv-gitlab-ci/data/github/shared/dockerhub-creds password | DOCKERHUB_PASSWORD ;
Expand Down Expand Up @@ -387,7 +388,7 @@ jobs:
SKIP_INGRESS_IMAGE_CREATION: true
SKIP_E2E_IMAGE_CREATION: true
WALLARM_ENABLED: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.user_token }}
WALLARM_API_HOST: ${{ steps.secrets.outputs.api_host }}
DOCKERHUB_USER: ${{ steps.secrets.outputs.DOCKERHUB_USER }}
DOCKERHUB_PASSWORD: ${{ steps.secrets.outputs.DOCKERHUB_PASSWORD }}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/run-chart-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

KIND_LOG_LEVEL="1"

# generate unique group name
export NODE_GROUP_NAME="github-ingress-$(tr -dc A-Za-z0-9 </dev/urandom | head -c 12; echo)"

if [ -n "${DEBUG}" ]; then
set -x
KIND_LOG_LEVEL="6"
Expand Down Expand Up @@ -64,6 +67,7 @@ DOCKERHUB_PASSWORD="${DOCKERHUB_PASSWORD:-fake_password}"
HELM_EXTRA_ARGS="--timeout 240s"
HELM_EXTRA_SET_ARGS="\
--set controller.wallarm.token=${WALLARM_API_TOKEN} \
--set controller.wallarm.nodeGroup=${NODE_GROUP_NAME} \
--set controller.wallarm.enabled=true \
--set controller.image.repository=wallarm/ingress-controller \
--set controller.image.tag=1.0.0-dev \
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/run-e2e-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ set -o errexit
set -o nounset
set -o pipefail

# generate unique group name
export NODE_GROUP_NAME="github-ingress-$(tr -dc A-Za-z0-9 </dev/urandom | head -c 12; echo)"

RED='\e[35m'
NC='\e[0m'
BGREEN='\e[32m'
Expand Down Expand Up @@ -105,6 +108,7 @@ kubectl run --rm \
--env="WALLARM_ENABLED=${WALLARM_ENABLED:-false}" \
--env="WALLARM_API_TOKEN=${WALLARM_API_TOKEN:-}" \
--env="WALLARM_API_HOST=${WALLARM_API_HOST:-}" \
--env="NODE_GROUP_NAME=${NODE_GROUP_NAME:-}" \
--env="HTTPBUN_IMAGE=${HTTPBUN_IMAGE}" \
--overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "ingress-nginx-e2e","imagePullSecrets":[{"name":"dockerhub-secret"}]}}' \
e2e --image=nginx-ingress-controller:e2e
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/run-kind-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ SKIP_INGRESS_IMAGE_CREATION="${SKIP_INGRESS_IMAGE_CREATION:-false}"
SKIP_E2E_IMAGE_CREATION="${SKIP_E2E_IMAGE_CREATION:=false}"
SKIP_CLUSTER_CREATION="${SKIP_CLUSTER_CREATION:-false}"

# generate unique group name
export NODE_GROUP_NAME="github-ingress-$(tr -dc A-Za-z0-9 </dev/urandom | head -c 12; echo)"

if ! command -v kind --version &> /dev/null; then
echo "kind is not installed. Use the package manager or visit the official site https://kind.sigs.k8s.io/"
exit 1
Expand Down
1 change: 1 addition & 0 deletions test/smoke/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function check_mandatory_vars() {
WEBHOOK_UUID
SMOKE_REGISTRY_TOKEN
SMOKE_REGISTRY_SECRET
NODE_GROUP_NAME
)

env_list=""
Expand Down
13 changes: 2 additions & 11 deletions test/smoke/run-smoke-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o errexit
set -o nounset
set -o pipefail

#import functions
# import functions
source "${PWD}/test/smoke/functions.sh"

# check if all mandatory vars was defined
Expand Down Expand Up @@ -62,15 +62,6 @@ if ! kubectl get secret "${SMOKE_IMAGE_PULL_SECRET_NAME}" &> /dev/null; then
[email protected]
fi

echo "Retrieving Wallarm Node UUID ..."
POD=$(kubectl get pod -l "app.kubernetes.io/component=controller" -o=name | cut -d/ -f 2)
NODE_UUID=$(kubectl exec "${POD}" -c controller -- cat /opt/wallarm/etc/wallarm/node.yaml | grep uuid | awk '{print $2}' | xargs)
if [[ -z "${NODE_UUID}" ]]; then
echo "Failed to retrieve Wallarm Node UUID"
get_logs_and_fail
fi
echo "Node UUID: ${NODE_UUID}"

RAND_NUM="${RANDOM}${RANDOM}${RANDOM}"
RAND_NUM=${RAND_NUM:0:10}

Expand All @@ -90,7 +81,7 @@ spec:
- command: [sleep, infinity]
env:
- {name: NODE_BASE_URL, value: "${NODE_BASE_URL}"}
- {name: NODE_UUID, value: "${NODE_UUID}"}
- {name: NODE_GROUP_NAME, value: "${NODE_GROUP_NAME}"}
- {name: WALLARM_API_HOST, value: "${WALLARM_API_HOST}"}
- {name: WALLARM_API_PRESET, value: "${WALLARM_API_PRESET}"}
- {name: API_CA_VERIFY, value: "${WALLARM_API_CA_VERIFY}"}
Expand Down
7 changes: 6 additions & 1 deletion test/smoke/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#import functions
# import functions
source "${PWD}/test/smoke/functions.sh"

# generate unique group name
export NODE_GROUP_NAME="github-ingress-$(tr -dc A-Za-z0-9 </dev/urandom | head -c 12; echo)"
echo "[test-env] random node group name: ${NODE_GROUP_NAME}..."

# check if all mandatory vars was defined
check_mandatory_vars

Expand Down Expand Up @@ -135,6 +139,7 @@ controller:
token: ${WALLARM_API_TOKEN}
apiHost: ${WALLARM_API_HOST}
apiCaVerify: ${WALLARM_API_CA_VERIFY}
nodeGroup: ${NODE_GROUP_NAME}
fallback: "off"
cron:
commands:
Expand Down

0 comments on commit e527899

Please sign in to comment.