forked from MiniMax-AI/OpenAgentCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Deploy the control plane to Kubernetes from one source commit #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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,85 @@ | ||
| name: Setup kubectl | ||
| description: Install kubectl and point it at the deployment cluster | ||
|
|
||
| inputs: | ||
| kubeconfig: | ||
| description: Base64-encoded kubeconfig | ||
| required: true | ||
| expected-cluster-uid: | ||
| description: UID of the target cluster kube-system namespace | ||
| required: true | ||
| server: | ||
| description: Override the cluster's API server URL; empty keeps the kubeconfig's own | ||
| required: false | ||
| default: '' | ||
| insecure-skip-tls-verify: | ||
| description: Skip API server certificate verification; only for a server address the certificate does not name | ||
| required: false | ||
| default: 'false' | ||
| version: | ||
| description: kubectl version to install when the runner has none | ||
| required: false | ||
| default: v1.34.1 | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - shell: bash | ||
| env: | ||
| KUBECONFIG_CONTENT: ${{ inputs.kubeconfig }} | ||
| EXPECTED_CLUSTER_UID: ${{ inputs.expected-cluster-uid }} | ||
| SERVER: ${{ inputs.server }} | ||
| INSECURE: ${{ inputs.insecure-skip-tls-verify }} | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "$KUBECONFIG_CONTENT" ]; then | ||
| echo "::error::The kubeconfig secret is not configured for this GitHub Environment." | ||
| exit 1 | ||
| fi | ||
| if ! command -v kubectl >/dev/null 2>&1; then | ||
| curl --fail --show-error --silent --location \ | ||
| -o "$RUNNER_TEMP/kubectl" \ | ||
| "https://dl.k8s.io/release/${VERSION}/bin/linux/amd64/kubectl" | ||
| install -m 0755 "$RUNNER_TEMP/kubectl" /usr/local/bin/kubectl | ||
| fi | ||
|
|
||
| # The kubeconfig is a credential: write it privately and keep it out of the log. | ||
| install -d -m 0700 "$HOME/.kube" | ||
| umask 077 | ||
| printf '%s' "$KUBECONFIG_CONTENT" | base64 -d > "$HOME/.kube/config" | ||
| chmod 600 "$HOME/.kube/config" | ||
|
|
||
| # Every later kubectl call uses the current context, so patch that | ||
| # context's cluster rather than whichever one comes first. | ||
| context="$(kubectl config current-context)" | ||
| cluster="$(kubectl config view -o jsonpath="{.contexts[?(@.name=='$context')].context.cluster}")" | ||
| if [ -z "$cluster" ]; then | ||
| echo "::error::The kubeconfig's current context names no cluster." | ||
| exit 1 | ||
| fi | ||
| echo "Using context $context, cluster $cluster" | ||
| arguments=() | ||
| if [ -n "$SERVER" ]; then | ||
| arguments+=("--server=$SERVER") | ||
| fi | ||
| if [ "$INSECURE" = "true" ]; then | ||
| arguments+=(--insecure-skip-tls-verify=true) | ||
| fi | ||
| if [ "${#arguments[@]}" -gt 0 ]; then | ||
| kubectl config set-cluster "$cluster" "${arguments[@]}" | ||
| fi | ||
| if [ "$INSECURE" = "true" ]; then | ||
| # kubectl rejects a configuration that carries both a certificate authority | ||
| # and the insecure flag. A property path splits on dots, so a cluster name | ||
| # containing one has to escape them. | ||
| escaped="${cluster//./\\.}" | ||
| kubectl config unset "clusters.${escaped}.certificate-authority-data" >/dev/null | ||
| kubectl config unset "clusters.${escaped}.certificate-authority" >/dev/null | ||
| fi | ||
| actual_uid="$(kubectl get namespace kube-system -o jsonpath='{.metadata.uid}')" | ||
| if [ -z "$EXPECTED_CLUSTER_UID" ] || [ "$actual_uid" != "$EXPECTED_CLUSTER_UID" ]; then | ||
| echo "::error::The kubeconfig does not identify the expected production cluster." | ||
| exit 1 | ||
| fi | ||
| kubectl version --output=yaml | ||
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.
When a self-hosted runner does not already have
kubectl, this fallback runs as the runner account but writes directly to root-owned/usr/local/bin. A normal non-root runner therefore fails with permission denied before it can connect to the private cluster, despite this action claiming to install the missing binary. Install it under a runner-owned directory such as$RUNNER_TEMPand add that directory toPATH, or explicitly use the runner's privilege mechanism.Useful? React with 👍 / 👎.