Improve ArgoCD and fix CI
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
2a91ae1d80
commit
0fe8b14e78
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -151,17 +151,6 @@ jobs:
|
|||||||
aws --endpoint-url=http://localhost:4566 s3 mb s3://dagger-ci
|
aws --endpoint-url=http://localhost:4566 s3 mb s3://dagger-ci
|
||||||
aws --endpoint-url=http://localhost:4566 ecr create-repository --repository-name dagger-ci
|
aws --endpoint-url=http://localhost:4566 ecr create-repository --repository-name dagger-ci
|
||||||
|
|
||||||
- name: Setup ArgoCD infra
|
|
||||||
run: |
|
|
||||||
make install
|
|
||||||
dagger -w universe -e argocd-infra input text TestKubeconfig -f "$HOME"/.kube/config
|
|
||||||
dagger -w universe -e dagger-infra up
|
|
||||||
|
|
||||||
# Expose Argo API
|
|
||||||
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
|
|
||||||
curl localhost:8080
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Universe Test
|
- name: Universe Test
|
||||||
run: |
|
run: |
|
||||||
make universe-test
|
make universe-test
|
||||||
|
6
stdlib/.dagger/env/argocd/values.yaml
vendored
6
stdlib/.dagger/env/argocd/values.yaml
vendored
@ -4,8 +4,6 @@ name: argocd
|
|||||||
inputs:
|
inputs:
|
||||||
TestConfig.argocdConfig.server:
|
TestConfig.argocdConfig.server:
|
||||||
text: localhost:8080
|
text: localhost:8080
|
||||||
TestConfig.argocdConfig.token:
|
|
||||||
secret: ENC[AES256_GCM,data:TC8wCWyJ+yTkAQXBLLioVDUm4YfkMMgHEzcxyRBr/uwOErEYAWDE539dahcPclQYW/Ds7UVQIv+PMS+43zXSqIv5lde842IhOEIZwemCGnWrGy2yBC566WCYPxU16k76MzslwhJrYGDi4GF4zlIyvtVO6AbviumZqGT+wAq4/Z6KZ2CQTDWNf42ise2orGNsBTj7jqpazLO34A+Wt9USW/cJrSqU+BtAjGkoLZW65iGJ8ui8RdADxw5/A0rkdJaoN4mnSUi7yARpcmTdQBdo33385csTxxqy8oWw7OR4itUfzzWKbOprQph/EeEtxMtPAuHOB/9As/6dvIGcynwxPjw=,iv:xAb0eF1lCmNoaE9Tzfnq2uLB647DK2Cat2BZTPn272s=,tag:D2mfkvEAzVi34y7WYSg7JQ==,type:str]
|
|
||||||
sops:
|
sops:
|
||||||
kms: []
|
kms: []
|
||||||
gcp_kms: []
|
gcp_kms: []
|
||||||
@ -21,8 +19,8 @@ sops:
|
|||||||
WG5JdHlKYUlnZnZlMVNIRjczSld5ek0KF0z0UqtoGcYFFeOyMwIDAY1pyKosaOii
|
WG5JdHlKYUlnZnZlMVNIRjczSld5ek0KF0z0UqtoGcYFFeOyMwIDAY1pyKosaOii
|
||||||
IVqsMSYfj4+vz7mRd8HoXoSiSnuc7mLJek/izsdZtYUTfD/QnTC71Q==
|
IVqsMSYfj4+vz7mRd8HoXoSiSnuc7mLJek/izsdZtYUTfD/QnTC71Q==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
lastmodified: "2021-09-09T09:31:30Z"
|
lastmodified: "2021-09-09T12:42:58Z"
|
||||||
mac: ENC[AES256_GCM,data:khUMYQdGj8qwNd7TZa2TPJIeOD9WjOn6LpNhqnZ2VZPOHWzre56MSytBS65h2bqgB5ljaYOM8qR8qc6UzSFhcNOBaAKofOYfuD1Zy6BcjNzNbJ9wvQE9qvT5o25VHsLk+fNhJt04wNdGdWjPuJNJrTTGLj82CXKCUPGyxvV72Pg=,iv:ut+MuwUELE+xu+I1G6NmqFrxu39++2pr96SHShQ5scI=,tag:5Fa6WPRo7R9UN5L7ankYzA==,type:str]
|
mac: ENC[AES256_GCM,data:CMNfY3kBAbDOkyh1s3csD7uGToV/5TubN/0z3NaG0rVOeHzgPx//PUw7jfhBe3iTCe5m7z5jpGwbI9h6+GoANrsPX887/XYvC22JLQ7vqfOqJYOrYY9YbEJnYK+GXthQB7bqn5Yh2+yiNRVk9vHJkXyhqea9/ud32kiKhG2tE3o=,iv:eT3sjgmh4NF1sS+MSsOEZbgvAiWOwep72aM2fDenG0s=,tag:HcKVlnDpn6kQxFdlKSCALg==,type:str]
|
||||||
pgp: []
|
pgp: []
|
||||||
encrypted_suffix: secret
|
encrypted_suffix: secret
|
||||||
version: 3.7.1
|
version: 3.7.1
|
||||||
|
@ -25,8 +25,8 @@ import (
|
|||||||
// Destination namespace
|
// Destination namespace
|
||||||
namespace: dagger.#Input & {*"default" | string}
|
namespace: dagger.#Input & {*"default" | string}
|
||||||
|
|
||||||
_ctr: os.Container & {
|
ctr: os.#Container & {
|
||||||
from: #CLI & {
|
image: #CLI & {
|
||||||
"config": config
|
"config": config
|
||||||
}
|
}
|
||||||
command: #"""
|
command: #"""
|
||||||
|
@ -18,8 +18,11 @@ import (
|
|||||||
// ArgoCD project
|
// ArgoCD project
|
||||||
project: *"default" | dagger.#Input & {string}
|
project: *"default" | dagger.#Input & {string}
|
||||||
|
|
||||||
// ArgoCD authentication token
|
// Username
|
||||||
token: dagger.#Secret & dagger.#Input
|
username: dagger.#Input & {string}
|
||||||
|
|
||||||
|
// Password
|
||||||
|
password: dagger.#Input & {dagger.#Secret}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-usable CLI component
|
// Re-usable CLI component
|
||||||
@ -46,27 +49,17 @@ import (
|
|||||||
env: VERSION: config.version
|
env: VERSION: config.version
|
||||||
},
|
},
|
||||||
|
|
||||||
// Write config file
|
// Login to ArgoCD server
|
||||||
op.#Exec & {
|
op.#Exec & {
|
||||||
args: ["sh", "-c",
|
args: ["sh", "-c", #"""
|
||||||
#"""
|
argocd login "$ARGO_SERVER" --username "$ARGO_USERNAME" --password $(cat /run/secrets/password) --insecure
|
||||||
mkdir ~/.argocd && cat > ~/.argocd/config << EOF
|
"""#,
|
||||||
contexts:
|
|
||||||
- name: "$SERVER"
|
|
||||||
server: "$SERVER"
|
|
||||||
user: "$SERVER"
|
|
||||||
current-context: "$SERVER"
|
|
||||||
servers:
|
|
||||||
- grpc-web-root-path: ""
|
|
||||||
server: "$SERVER"
|
|
||||||
users:
|
|
||||||
- auth-token: $(cat /run/secrets/token)
|
|
||||||
name: "$SERVER"
|
|
||||||
EOF
|
|
||||||
"""#,
|
|
||||||
]
|
]
|
||||||
mount: "/run/secrets/token": secret: config.token
|
env: {
|
||||||
env: SERVER: config.server
|
ARGO_SERVER: config.server
|
||||||
|
ARGO_USERNAME: config.username
|
||||||
|
}
|
||||||
|
mount: "/run/secrets/password": secret: config.password
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,12 @@ import (
|
|||||||
op.#Exec & {
|
op.#Exec & {
|
||||||
args: ["sh", "-c",
|
args: ["sh", "-c",
|
||||||
#"""
|
#"""
|
||||||
ls ~/.argocd
|
// FIXME JQ failed
|
||||||
cat ~/.argocd/config
|
|
||||||
argocd app get "$APPLICATION" --output json | jq '{health:.status.health.status,sync:.status.sync.status,namespace:.spec.destination.namespace,server:.spec.destination.server,urls:.status.summary.externalURLs|join(","),state:.status.operationState.message}' > /output.json
|
argocd app get "$APPLICATION" --output json | jq '{health:.status.health.status,sync:.status.sync.status,namespace:.spec.destination.namespace,server:.spec.destination.server,urls:.status.summary.externalURLs|join(","),state:.status.operationState.message}' > /output.json
|
||||||
"""#,
|
"""#,
|
||||||
]
|
]
|
||||||
env: {
|
env: {
|
||||||
APPLICATION: name
|
APPLICATION: name
|
||||||
ARGOCD_OPTS: "--port-forward-namespace argocd"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
// Wait the application to sync correctly
|
// Wait the application to sync correctly
|
||||||
wait: dagger.#Input & {*false | bool}
|
wait: dagger.#Input & {*false | bool}
|
||||||
|
|
||||||
_ctr: os.#Container & {
|
ctr: os.#Container & {
|
||||||
image: #CLI & {
|
image: #CLI & {
|
||||||
"config": config
|
"config": config
|
||||||
}
|
}
|
||||||
|
@ -6,23 +6,30 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
TestConfig: argocdConfig: #Config & {
|
TestConfig: argocdConfig: #Config & {
|
||||||
version: dagger.#Input & {*"v2.0.5" | string}
|
version: dagger.#Input & {*"v2.0.5" | string}
|
||||||
server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
|
server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
|
||||||
token: dagger.#Input & {dagger.#Secret}
|
username: dagger.#Input & {*"admin" | string}
|
||||||
|
password: dagger.#Input & {dagger.#Secret}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestArgoCD: os.#Container & {
|
TestClient: os.#Container & {
|
||||||
image: #CLI & {
|
image: #CLI & {
|
||||||
config: TestConfig.argocdConfig
|
config: TestConfig.argocdConfig
|
||||||
}
|
}
|
||||||
always: true
|
|
||||||
command: #"""
|
command: #"""
|
||||||
argocd version --output json | jq -e 'all(.client.Version; startswith("$VERSION"))'
|
argocd account list | grep "$ARGOCD_USERNAME"
|
||||||
"""#
|
"""#
|
||||||
env: VERSION: TestConfig.argocdConfig.version
|
env: ARGOCD_USERNAME: TestConfig.argocdConfig.username
|
||||||
}
|
}
|
||||||
|
|
||||||
TestArgoCDStatus: #Status & {
|
TestApp: #App & {
|
||||||
config: TestConfig.argocdConfig
|
config: TestConfig.argocdConfig
|
||||||
name: "test"
|
name: "daggerci-test"
|
||||||
|
repo: "https://github.com/argoproj/argocd-example-apps.git"
|
||||||
|
path: "guestbook"
|
||||||
|
}
|
||||||
|
|
||||||
|
TestArgoCDStatus: #Sync & {
|
||||||
|
config: TestApp.config
|
||||||
|
application: TestApp.name
|
||||||
}
|
}
|
||||||
|
@ -219,21 +219,20 @@ setup() {
|
|||||||
skip_unless_local_kube
|
skip_unless_local_kube
|
||||||
|
|
||||||
# Deploy argoCD infra
|
# Deploy argoCD infra
|
||||||
# dagger -e argocd-infra input text TestKubeconfig -f "$HOME"/.kube/config
|
dagger -e argocd-infra input text TestKubeconfig -f "$HOME"/.kube/config
|
||||||
#dagger -e argocd-infra up
|
dagger -e argocd-infra up
|
||||||
# pid=$!
|
|
||||||
|
|
||||||
curl localhost:8080
|
# Forward port
|
||||||
|
kubectl port-forward svc/argocd-server -n argocd 8080:443 >/dev/null 2>/dev/null &
|
||||||
|
pid=$!
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
# Run test
|
||||||
|
dagger -e argocd input secret TestConfig.argocdConfig.password "$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)"
|
||||||
|
dagger -e up
|
||||||
|
dagger -e argocd input unset TestConfig.argocdConfig.password
|
||||||
|
|
||||||
# Kill Pid
|
# Kill Pid
|
||||||
#check_pid=$(pgrep "$pid")
|
pkill kubectl
|
||||||
#if [ "$pid" -eq "$check_pid" ]; then
|
|
||||||
# kill "$pid"
|
|
||||||
#fi
|
|
||||||
# skip "ArgoCD CI secrets not yet generated - Infra not implemented yet"
|
|
||||||
# dagger -e argocd input secret TestConfig.argocdConfig.token "$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && echo)"
|
|
||||||
# dagger -e argocd up
|
|
||||||
|
|
||||||
# Kill forward
|
|
||||||
# >&2 echo "kill pid"
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user