-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge release/v2/preview to main (#71)
* Not running on windows node (#30) * Bump up version to 2.0.0-preview (#42) * Workload identity support namespaced service account (#39) * Workload identity support namespaced service account * feedback * Feedback * Upgrade package (#44) * fix vulnerability * fix go version * update * update * update * update * update * update controller runtime * upgrade azsecrets package * update ci * update patched version * update * revert version * upgrade packages * update ci * revert * deduplicate feature flags (#50) * Treat get settings from one client failure as warning (#48) * Add node affinity and toleration configuration (#46) * K8s provider conformance test plugin (#43) * k8s provider conformance test plugin * rename * remove docker hub dependency * replace curl with wget * add version file * Setup golangci lint action (#51) * setup golangci lint action * fix linting error * update ci * update * add lint in makefile * Add Correlation Context header for extension (#47) * Add Correlation Context header for extension * Add more context * Add Host and RequestType in correlation context * Remove the kv refresh * update extension test plugin conformance file (#52) * added timeout parameter in golintCI (#54) * Revise the error message for selector object verification (#56) * Bump up version to 2.0.0 (#58) * Add data collection section in readme (#57) * Require to opt-in for the global service account (#60) * Require to opt in the global service account * Rename * Fix vulnerability (#68) * fix vulnerability * specify go version in golang lint ci --------- Co-authored-by: Richard chen <[email protected]>
- Loading branch information
1 parent
280fdf3
commit e904f57
Showing
32 changed files
with
891 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- 'release/**' | ||
pull_request: | ||
branches: | ||
- main | ||
- 'release/**' | ||
|
||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
# pull-requests: read | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.6 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 | ||
args: --timeout 10m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM mcr.microsoft.com/azure-cli:latest | ||
|
||
RUN pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pytest pytest-xdist filelock junit_xml kubernetes==24.2.0 azure.identity msrestazure azure-mgmt-hybridkubernetes azure-mgmt-kubernetesconfiguration==2.0.0 | ||
RUN wget https://storage.googleapis.com/kubernetes-release/release/$(wget -qO- https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | ||
RUN chmod +x ./kubectl | ||
RUN mv ./kubectl /usr/local/bin | ||
|
||
COPY arc/conformance/plugin/arc_conformance.sh /arc/arc_conformance.sh | ||
COPY arc/conformance/plugin/setup_failure_handler.py /arc/setup_failure_handler.py | ||
|
||
RUN ["chmod", "+x", "/arc/arc_conformance.sh"] | ||
ENTRYPOINT ["/arc/arc_conformance.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
results_dir="${RESULTS_DIR:-/tmp/results}" | ||
|
||
waitForArc() { | ||
ready=false | ||
max_retries=60 | ||
sleep_seconds=20 | ||
|
||
for i in $(seq 1 $max_retries) | ||
do | ||
status=$(helm ls -a -A -o json | jq '.[]|select(.name=="azure-arc").status' -r) | ||
if [ "$status" == "deployed" ]; then | ||
echo "helm release successful" | ||
ready=true | ||
break | ||
elif [ "$status" == "failed" ]; then | ||
echo "helm release failed" | ||
break | ||
else | ||
echo "waiting for helm release to be successful. Status - ${status}. Attempt# $i of $max_retries" | ||
sleep ${sleep_seconds} | ||
fi | ||
done | ||
|
||
echo "$ready" | ||
} | ||
|
||
saveResult() { | ||
# prepare the results for handoff to the Sonobuoy worker. | ||
cd "${results_dir}" | ||
# Sonobuoy worker expects a tar file. | ||
tar czf results.tar.gz ./* | ||
# Signal the worker by writing out the name of the results file into a "done" file. | ||
printf "%s/results.tar.gz" "${results_dir}" > "${results_dir}"/done | ||
} | ||
|
||
# Ensure that we tell the Sonobuoy worker we are done regardless of results. | ||
trap saveResult EXIT | ||
|
||
# initial environment variables for the plugin | ||
setEnviornmentVariables() { | ||
export JUNIT_OUTPUT_FILEPATH=/tmp/results/ | ||
export IS_ARC_TEST=true | ||
export CI_KIND_CLUSTER=true | ||
} | ||
|
||
# setup kubeconfig for conformance test | ||
setupKubeConfig() { | ||
KUBECTL_CONTEXT=azure-arc-appconfig-test | ||
APISERVER=https://kubernetes.default.svc/ | ||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) | ||
cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt > ca.crt | ||
|
||
kubectl config set-cluster ${KUBECTL_CONTEXT} \ | ||
--embed-certs=true \ | ||
--server=${APISERVER} \ | ||
--certificate-authority=./ca.crt 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
kubectl config set-credentials ${KUBECTL_CONTEXT} --token="${TOKEN}" 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
# Delete previous rolebinding if exists. And ignore the error if not found. | ||
kubectl delete clusterrolebinding clusterconnect-binding --ignore-not-found | ||
kubectl create clusterrolebinding clusterconnect-binding --clusterrole=cluster-admin --user="${OBJECT_ID}" 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
kubectl config set-context ${KUBECTL_CONTEXT} \ | ||
--cluster=${KUBECTL_CONTEXT} \ | ||
--user=${KUBECTL_CONTEXT} \ | ||
--namespace=default 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
kubectl config use-context ${KUBECTL_CONTEXT} 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
echo "INFO: KubeConfig setup complete" | ||
} | ||
|
||
# validate enviorment variables | ||
if [ -z "${TENANT_ID}" ]; then | ||
echo "ERROR: parameter TENANT_ID is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
if [ -z "${SUBSCRIPTION_ID}" ]; then | ||
echo "ERROR: parameter SUBSCRIPTION_ID is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
if [ -z "${AZURE_CLIENT_ID}" ]; then | ||
echo "ERROR: parameter AZURE_CLIENT_ID is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
if [ -z "${AZURE_CLIENT_SECRET}" ]; then | ||
echo "ERROR: parameter AZURE_CLIENT_SECRET is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
if [ -z "${CLUSTER_NAME}" ]; then | ||
echo "ERROR: parameter CLUSTER_NAME is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
if [ -z "${CLUSTER_RG}" ]; then | ||
echo "ERROR: parameter CLUSTER_RG is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
# OBJECT_ID is an id of the Service Principal created in conformance test subscription. | ||
if [ -z "${OBJECT_ID}" ]; then | ||
echo "ERROR: parameter OBJECT_ID is required." > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
fi | ||
|
||
# add az cli extensions | ||
az extension add --name k8s-extension | ||
|
||
# login with service principal | ||
az login --service-principal \ | ||
-u "${AZURE_CLIENT_ID}" \ | ||
-p "${AZURE_CLIENT_SECRET}" \ | ||
--tenant "${TENANT_ID}" 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
az account set --subscription "${SUBSCRIPTION_ID}" 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
# set environment variables | ||
setEnviornmentVariables | ||
|
||
# setup Kubeconfig | ||
setupKubeConfig | ||
|
||
# Wait for resources in ARC agents to come up | ||
echo "INFO: Waiting for ConnectedCluster to come up" | ||
waitSuccessArc="$(waitForArc)" | ||
if [ "${waitSuccessArc}" == false ]; then | ||
echo "helm release azure-arc failed" > "${results_dir}"/error | ||
python3 /arc/setup_failure_handler.py | ||
exit 1 | ||
else | ||
echo "INFO: ConnectedCluster is available" | ||
fi | ||
|
||
# register the KubernetesConfiguration resource provider | ||
az provider register --namespace Microsoft.KubernetesConfiguration | ||
|
||
echo "INFO: Creating extension" | ||
az k8s-extension create \ | ||
--name appconfigurationkubernetesprovider \ | ||
--extension-type Microsoft.AppConfiguration \ | ||
--cluster-name "${CLUSTER_NAME}" \ | ||
--resource-group "${CLUSTER_RG}" \ | ||
--cluster-type managedClusters \ | ||
--release-train preview 2> "${results_dir}"/error || python3 /arc/setup_failure_handler.py | ||
|
||
# wait for provider pods | ||
kubectl wait pod -n azappconfig-system --for=condition=Ready -l app.kubernetes.io/instance=azureappconfiguration.kubernetesprovider --timeout=5m | ||
|
||
# clean up test resources | ||
echo "INFO: cleaning up test resources" | ||
az k8s-extension delete \ | ||
--name appconfigurationkubernetesprovider \ | ||
--resource-group "${CLUSTER_RG}" \ | ||
--cluster-type managedClusters \ | ||
--cluster-name "${CLUSTER_NAME}" \ | ||
--force \ | ||
--yes \ | ||
--no-wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sonobuoy-config: | ||
driver: Job | ||
plugin-name: azure-arc-app-config-provider | ||
result-format: junit | ||
spec: | ||
image: mcr.microsoft.com/azure-app-configuration/extension-test-plugin:0.1.0 | ||
imagePullPolicy: Always | ||
name: plugin | ||
resources: {} | ||
volumes: | ||
- name: results | ||
emptyDir: {} | ||
volumeMounts: | ||
- mountPath: /tmp/results | ||
name: results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
from junit_xml import TestSuite, TestCase | ||
|
||
# Reading error message from error file | ||
with open('/tmp/results/error', 'r') as f: | ||
error_message = f.read() | ||
|
||
# Creating a junit report for setup failure | ||
test_case = TestCase('azure_app_configuration_provider_conformance_setup', 'azure_app_configuration_provider_conformance_setup') | ||
test_case.add_failure_info(error_message) | ||
test_cases = [test_case] | ||
test_suite = TestSuite("azure_app_configuration_provider_conformance", test_cases) | ||
|
||
with open('/tmp/results/results.xml', 'w') as f: | ||
TestSuite.to_file(f, [test_suite], prettyprint=False) | ||
|
||
# Exit with non-zero return code | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version":"0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.