Skip to content

Commit

Permalink
Remove unimplemented cluster providers
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-a-lane-ii committed Apr 12, 2024
1 parent 0c84cf5 commit faef6cf
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/actions/gke-kubeconfig/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ runs:
with:
credentials_json: ${{ inputs.gkeCredentials }}
create_credentials_file: true
- name: Install gke-gcloud-auth-plugin
uses: google-github-actions/setup-gcloud@v2
with:
install_components: gke-gcloud-auth-plugin
- name: Get cluster credentials using GitHub action
uses: google-github-actions/get-gke-credentials@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/provision-cluster/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Provision Cluster"
description: "Provision a Cluster"
inputs:
distribution:
description: "One of GKE, AKS, EKS, OpenShift, or Kubeception"
description: "GKE or Kubeception"
required: true
action:
description: "If set to expire then no cluster will be provisioned, but the action will still delete any expired clusters. Use this in a schedueled workflow to garbage collect orphaned clusters."
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/provision-cluster/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function create() {
const version = core.getInput("version");
const lifespan = core.getInput("lifespan");
const kubeconfigPath = core.getInput("kubeconfig");
const useAuthProvider = core.getInput("useAuthProvider");

let provider = registry.getProvider(distribution);

Expand All @@ -30,7 +31,10 @@ async function create() {
core.setOutput("location", cluster?.zone);

core.notice(`Creating ${distribution} cluster ${cluster.name} ...`);
let kubeconfig = await provider.makeKubeconfig(cluster);
let kubeconfig = await provider.makeKubeconfig(
cluster,
JSON.parse(useAuthProvider)
);
core.notice(`Cluster created: ${cluster.name}!`);
let contents = JSON.stringify(kubeconfig, undefined, 2) + "\n";
utils.writeFile(kubeconfigPath, contents);
Expand Down
57 changes: 56 additions & 1 deletion .github/actions/provision-cluster/lib/gke.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,62 @@ class Client {
}

// Make a functioning kubeconfig from a cluster object.
async makeKubeconfig(cluster) {
async makeKubeconfig(cluster, useAuthProvider = false) {
if (useAuthProvider) {
return this.makeKubeconfigUsingAuthProvider(cluster);
}

return this.makeKubeconfigWithToken(cluster);
}

async makeKubeconfigUsingAuthProvider(cluster) {
let kubeconfig = {
apiVersion: "v1",
kind: "Config",
clusters: [
{
cluster: {
"certificate-authority-data":
cluster.masterAuth.clusterCaCertificate,
server: `https://${cluster.endpoint}`,
},
name: "gke-cluster",
},
],
users: [
{
name: "gke-user",
user: {
exec: {
apiVersion: "client.authentication.k8s.io/v1beta1",
args: null,
command: "gke-gcloud-auth-plugin",
env: null,
installHint:
"Install gke-gcloud-auth-plugin for use with kubectl by following https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke",
interactiveMode: IfAvailable,

Check failure on line 138 in .github/actions/provision-cluster/lib/gke.js

View workflow job for this annotation

GitHub Actions / tests (20.x)

'IfAvailable' is not defined
provideClusterInfo: true,
},
},
},
],
contexts: [
{
context: {
cluster: "gke-cluster",
namespace: "default",
user: "gke-user",
},
name: "gke-context",
},
],
"current-context": "gke-context",
};

return kubeconfig;
}

async makeKubeconfigWithToken(cluster) {
let token = await this.client.auth.getAccessToken();

let kubeconfig = {
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ jobs:
fail-fast: false
matrix:
clusters:
- version: "1.27"
- version: "1.27"
useAuthProvider: "true"
- version: "1.27"
useAuthProvider: "false"
runs-on: ubuntu-latest
env:
GKE_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
Expand All @@ -25,15 +28,15 @@ jobs:
with:
distribution: GKE
version: ${{ matrix.clusters.version }}
kubeconfig: ${{ runner.temp}}/kubeconfig.yaml
kubeconfig: ${{ runner.temp }}/kubeconfig.yaml
gkeCredentials: ${{ env.GKE_CREDENTIALS }}
useAuthProvider: "false"
useAuthProvider: ${{ matrix.clusters.useAuthProvider }}
- name: "Get kubeconfig and cluster information"
run: |
set -e
kubectl config view
kubectl version
kubectl get pods -A
kubectl config view --kubeconfig ${{ runner.temp }}/kubeconfig.yaml
kubectl version --kubeconfig ${{ runner.temp }}/kubeconfig.yaml
kubectl get pods -A --kubeconfig ${{ runner.temp }}/kubeconfig.yaml
release_smoke_kubeception:
strategy:
Expand All @@ -52,11 +55,11 @@ jobs:
with:
distribution: Kubeception
version: ${{ matrix.clusters.version }}
kubeconfig: ${{ runner.temp}}/kubeconfig.yaml
kubeconfig: ${{ runner.temp }}/kubeconfig.yaml
kubeceptionToken: ${{ env.KUBECEPTION_TOKEN }}
- name: "Get kubeconfig and cluster information"
run: |
set -e
kubectl config view
kubectl version
kubectl get pods -A
kubectl config view --kubeconfig ${{ runner.temp }}/kubeconfig.yaml
kubectl version --kubeconfig ${{ runner.temp }}/kubeconfig.yaml
kubectl get pods -A --kubeconfig ${{ runner.temp }}/kubeconfig.yaml
2 changes: 0 additions & 2 deletions docs/GITHUB_ACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ The [provision-cluster](../provision-cluster/README.md) action can be used to pr

- Kubeception (k3s based)
- GKE
- EKS (unimplemented)
- AKS (unimplemented)

By including this github action in your workflow you can easily run the same test suite against any supported set of clusters:

Expand Down
2 changes: 1 addition & 1 deletion provision-cluster/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Provision Cluster"
description: "Provision a Cluster"
inputs:
distribution:
description: "One of GKE, AKS, EKS, OpenShift, or Kubeception"
description: "GKE or Kubeception"
required: true
action:
description: "If set to expire then no cluster will be provisioned, but the action will still delete any expired clusters. Use this in a schedueled workflow to garbage collect orphaned clusters."
Expand Down

0 comments on commit faef6cf

Please sign in to comment.