Skip to content
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

feat(agent): add vcluster crd and controller #259

Merged
merged 13 commits into from
Sep 5, 2024

Conversation

floreks
Copy link
Member

@floreks floreks commented Aug 28, 2024

  • Added a new virtual cluster CRD and controller
    • Register a new virtual cluster in the API
    • Install the virtual cluster with helm using vcluster chart
    • Install agent inside the created virtual cluster
  • Minor changes to the helm logic template package to be able to reuse added repositories

CRD

apiVersion: v1
kind: Namespace
metadata:
  name: vcluster
---
apiVersion: v1
kind: Secret
metadata:
  name: sebastian-vcluster-basic-console-token
  namespace: vcluster
stringData:
  token: "CHANGEME"
---
apiVersion: deployments.plural.sh/v1alpha1
kind: VirtualCluster
metadata:
  name: sebastian
  namespace: vcluster
spec:
  kubeconfigRef:
    name: vc-sebastian-vcluster-basic
  credentialsRef:
    name: sebastian-vcluster-basic-console-token
    key: token

CRD (for testing locally)

apiVersion: v1
kind: Namespace
metadata:
  name: vcluster
---
apiVersion: v1
kind: Secret
metadata:
  name: sebastian-vcluster-basic-console-token
  namespace: vcluster
stringData:
  token: "CHANGEME"
---
apiVersion: deployments.plural.sh/v1alpha1
kind: VirtualCluster
metadata:
  name: sebastian-vcluster-basic
  namespace: vcluster
spec:
  kubeconfigRef:
    name: vc-sebastian-vcluster-basic
  credentialsRef:
    name: sebastian-vcluster-basic-console-token
    key: token
  helm:
    vcluster:
      values:
        exportKubeConfig:
          server: https://localhost:8443

Copy link

linear bot commented Aug 28, 2024

@@ -1,4 +1,4 @@
FROM golang:1.22.4-alpine3.20 as builder
FROM golang:1.22.6-alpine3.20 AS builder

Check notice

Code scanning / Trivy

No HEALTHCHECK defined Low

Artifact: Dockerfile
Type: dockerfile
Vulnerability DS026
Severity: LOW
Message: Add HEALTHCHECK instruction in your Dockerfile
Link: DS026
@michaeljguarino
Copy link
Member

how do you customize the helm values for installing our agent in the cluster w/ this structure?

i think a single crd to install vcluster + agent is not a bad idea (my original thought was you'd just use a service deployment for the vcluster though), but we also need to be able to specify agent helm values and helm repository

@michaeljguarino
Copy link
Member

Oh wait there's helm values for vcluster plus the agent, that's nice

return *in.RepoUrl
}

type VClusterHelmConfiguration struct {
Copy link
Member

@michaeljguarino michaeljguarino Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you inline the helm configuration struct for vcluster and agent? Suppose it's nice for the types to self-document

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just not to add an additional level to access the structure. Initially I have used HelmConfiguration directly, but I wanted to have some methods that can default values required to initialize cluster/agent such as repo url or chart name. This way structure access looks the same from the outside but there are different method implementations.

@michaeljguarino
Copy link
Member

I think we should still want to support separately created vclusters. So if we could add a bool field to the spec specifying maybe external and bypass the creation of the vcluster helm chart (so either people can manage that themselves, via Plural service deployment or loft.sh's tooling) they would be able to.

@floreks
Copy link
Member Author

floreks commented Aug 30, 2024

Ok, so when external flag is set then we only upsert to the API, install the agent using provided kubeconfig ref and skip the vcluster chart installation?

@michaeljguarino
Copy link
Member

Ok, so when external flag is set then we only upsert to the API, install the agent using provided kubeconfig ref and skip the vcluster chart installation?

Yeah precisely

@floreks floreks merged commit c98827a into main Sep 5, 2024
33 checks passed
@floreks floreks deleted the sebastian/prod-2544-virtualcluster-crd branch September 5, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants