-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Splitting functional tests as cloud and non-cloud #7716
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4df6021
Splitting functional tests as cloud and non-cloud
ytimocin 2f9a0a3
Fixing a format issue
ytimocin c4d4c29
Reverting back to local registry
ytimocin a1e38a9
Adding a secure local registry
ytimocin 9090888
Addressing comments
ytimocin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
name: "Create a KinD cluster" | ||
description: | | ||
Create a KinD cluster. | ||
inputs: | ||
secure: | ||
description: "Whether the KinD cluster should be created with a secure local registry configuration" | ||
required: false | ||
default: "false" | ||
temp-cert-dir: | ||
description: "The temporary directory where the certificates are stored" | ||
required: false | ||
default: "" | ||
kind-version: | ||
description: "The version of KinD to install" | ||
required: false | ||
default: "v0.23.0" | ||
with-local-registry: | ||
description: "Whether the KinD cluster should be created with a local registry configuration" | ||
required: false | ||
default: "false" | ||
registry-name: | ||
description: "The name of the local registry" | ||
required: true | ||
default: "radius-registry" | ||
registry-server: | ||
description: "The server name for the local registry" | ||
required: true | ||
default: "localhost" | ||
registry-port: | ||
description: "The port for the local registry" | ||
required: true | ||
default: "5000" | ||
rynowak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install KinD | ||
shell: bash | ||
run: | | ||
curl -sSLo "kind" "https://github.com/kubernetes-sigs/kind/releases/download/${{ inputs.kind-version }}/kind-linux-amd64" | ||
chmod +x ./kind | ||
|
||
- name: Create a KinD cluster without a local registry | ||
if: ${{ inputs.with-local-registry == 'false' }} | ||
shell: bash | ||
run: | | ||
# https://kind.sigs.k8s.io/docs/user/local-registry/ | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
EOF | ||
|
||
- name: Create a KinD cluster with an insecure local registry | ||
if: ${{ inputs.with-local-registry == 'true' && inputs.secure == 'false' }} | ||
shell: bash | ||
run: | | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry] | ||
config_path = "/etc/containerd/certs.d" | ||
EOF | ||
|
||
REGISTRY_DIR="/etc/containerd/certs.d/localhost:${{ inputs.registry-port }}" | ||
for node in $(kind get nodes); do | ||
docker exec "${node}" mkdir -p "${REGISTRY_DIR}" | ||
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml" | ||
[host."http://${{ inputs.registry-name }}:5000"] | ||
EOF | ||
done | ||
|
||
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${{ inputs.registry-name }}")" = 'null' ]; then | ||
docker network connect "kind" "${reg_name}" | ||
fi | ||
|
||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "localhost:${{ inputs.registry-port }}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF | ||
|
||
# Reference: https://kind.sigs.k8s.io/docs/user/local-registry/ | ||
|
||
- name: Create a KinD cluster with a secure local registry | ||
if: ${{ inputs.with-local-registry == 'true' && inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
# Create the cluster with necessary configurations for the secure local registry | ||
cat <<EOF | kind create cluster --config=- | ||
ytimocin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraMounts: | ||
- containerPath: "/etc/containerd/certs.d/${{ inputs.registry-name }}" | ||
hostPath: "${{ inputs.temp-cert-dir }}/certs/${{ inputs.registry-server }}" | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry] | ||
config_path = "/etc/containerd/certs.d" | ||
EOF | ||
|
||
# Create the directory for the certificates and add the certificate to the system trust store | ||
LOCALHOST_DIR="/etc/containerd/certs.d/${{ inputs.registry-server }}:${{ inputs.registry-port }}" | ||
RADIUS_DIR="/etc/containerd/certs.d/${{ inputs.registry-name }}:${{ inputs.registry-port }}" | ||
|
||
for node in $(kind get nodes); do | ||
docker exec "${node}" mkdir -p "${LOCALHOST_DIR}" | ||
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${LOCALHOST_DIR}/hosts.toml" | ||
[host."http://${{ inputs.registry-name }}:${{ inputs.registry-port }}"] | ||
capabilities = ["pull", "resolve", "push"] | ||
skip_verify = true | ||
EOF | ||
|
||
docker exec "${node}" mkdir -p "${RADIUS_DIR}" | ||
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${RADIUS_DIR}/hosts.toml" | ||
[host."http://${{ inputs.registry-name }}:${{ inputs.registry-port }}"] | ||
capabilities = ["pull", "resolve", "push"] | ||
skip_verify = true | ||
EOF | ||
|
||
docker exec "${node}" systemctl restart containerd | ||
done | ||
|
||
# Connect the registry to the KinD network | ||
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${{ inputs.registry-name }}")" = 'null' ]; then | ||
docker network connect "kind" "${{ inputs.registry-name }}" | ||
fi | ||
|
||
# Document the local registry | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "${{ inputs.registry-name }}:${{ inputs.registry-port }}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF |
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,123 @@ | ||
name: "Create a local registry" | ||
description: | | ||
This action creates a local registry for the images to be pushed to. | ||
It uses the `docker` CLI to create a registry container and then starts it. | ||
The registry is then available at `localhost:5000` by default. | ||
inputs: | ||
secure: | ||
description: "Whether the registry should be secure or not" | ||
required: false | ||
default: "false" | ||
registry-name: | ||
description: "The name of the local registry" | ||
required: false | ||
default: "radius-registry" | ||
registry-server: | ||
description: "The server name for the local registry" | ||
required: false | ||
default: "localhost" | ||
registry-port: | ||
description: "The port for the local registry" | ||
required: false | ||
default: "5000" | ||
outputs: | ||
temp-cert-dir: | ||
description: "The temporary directory where the certificates are stored" | ||
value: ${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
runs: | ||
rynowak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using: "composite" | ||
steps: | ||
- name: Create temporary directory for certificates | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
id: create-temp-cert-dir | ||
run: | | ||
# Create a temporary directory to store the certificates | ||
temp_cert_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'temp_cert_dir') | ||
echo "TEMP_CERT_DIR=$temp_cert_dir" >> $GITHUB_OUTPUT | ||
|
||
- name: Create certificates for local registry | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
create_openssl_cfg() { | ||
CFG=$( | ||
cat <<'EOF' | ||
[req] | ||
distinguished_name = subject | ||
x509_extensions = x509_ext | ||
prompt = no | ||
|
||
[subject] | ||
CN = localhost | ||
|
||
[x509_ext] | ||
basicConstraints = critical, CA:TRUE | ||
subjectKeyIdentifier = hash | ||
authorityKeyIdentifier = keyid:always, issuer:always | ||
keyUsage = critical, cRLSign, digitalSignature, keyCertSign | ||
nsComment = "OpenSSL Generated Certificate" | ||
subjectAltName = @alt_names | ||
|
||
[alt_names] | ||
DNS.1 = ${{ inputs.registry-name }} | ||
DNS.2 = ${{ inputs.registry-server }} | ||
EOF | ||
) | ||
echo "$CFG" | ||
} | ||
|
||
TEMP_CERT_DIR=${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
|
||
pushd $TEMP_CERT_DIR | ||
# Create the directory for the certificates | ||
mkdir -p certs/${{ inputs.registry-server }} | ||
|
||
echo "==== Generate the openssl config" | ||
create_openssl_cfg >req.cnf | ||
|
||
echo "==== Create the self signed certificate certificate and client key files" | ||
openssl req -x509 \ | ||
-nodes \ | ||
-days 365 \ | ||
-newkey rsa:4096 \ | ||
-keyout certs/${{ inputs.registry-server }}/client.key \ | ||
-out certs/${{ inputs.registry-server }}/client.crt \ | ||
-config req.cnf \ | ||
-sha256 | ||
|
||
- name: Add the certificate to the system trust store | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
TEMP_CERT_DIR=${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
sudo apt install ca-certificates | ||
sudo cp $TEMP_CERT_DIR/certs/${{ inputs.registry-server }}/client.crt /usr/local/share/ca-certificates/${{ inputs.registry-server }}.crt | ||
sudo cp $TEMP_CERT_DIR/certs/${{ inputs.registry-server }}/client.crt /usr/local/share/ca-certificates/${{ inputs.registry-name }}.crt | ||
sudo update-ca-certificates | ||
|
||
- name: Create secure Docker registry | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
TEMP_CERT_DIR=${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
echo "==== Create secure Docker registry" | ||
docker run -d \ | ||
-p ${{ inputs.registry-port }}:5000 \ | ||
--restart=always \ | ||
--name ${{ inputs.registry-name }} \ | ||
-v $TEMP_CERT_DIR/certs/${{ inputs.registry-server }}:/certs \ | ||
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/client.crt \ | ||
-e REGISTRY_HTTP_TLS_KEY=/certs/client.key \ | ||
registry:2 | ||
|
||
- name: Create insecure Docker registry | ||
if: ${{ inputs.secure == 'false' }} | ||
shell: bash | ||
run: | | ||
echo "==== Create insecure Docker registry" | ||
docker run -d \ | ||
-p ${{ inputs.registry-port }}:5000 \ | ||
--restart=always \ | ||
--name ${{ inputs.registry-name }} \ | ||
registry:2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,3 @@ runs: | |
shell: bash | ||
run: chmod +x rad | ||
working-directory: dist | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion:
cert-dir
. Saying "temp" doesn't really make sense as a parameter name. I think it's a translation from the original code.