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

vcluster release v0.15.2 #183

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions charts/vcluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
24 changes: 24 additions & 0 deletions charts/vcluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
description: vcluster - Virtual Kubernetes Clusters
home: https://vcluster.com
icon: https://static.loft.sh/branding/logos/vcluster/vertical/vcluster_vertical.svg
keywords:
- developer
- development
- sharing
- share
- multi-tenancy
- tenancy
- cluster
- space
- namespace
- vcluster
- vclusters
maintainers:
- name: LoftLabs
name: vcluster
sources:
- https://github.com/loft-sh/vcluster
type: application
version: 0.15.2
appVersion: 0.15.2
60 changes: 60 additions & 0 deletions charts/vcluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## vcluster

### **[GitHub](https://github.com/loft-sh/vcluster)** • **[Website](https://www.vcluster.com)** • **[Quickstart](https://www.vcluster.com/docs/getting-started/setup)** • **[Documentation](https://www.vcluster.com/docs/what-are-virtual-clusters)** • **[Blog](https://loft.sh/blog)** • **[Twitter](https://twitter.com/loft_sh)** • **[Slack](https://slack.loft.sh/)**

Create fully functional virtual Kubernetes clusters - Each vcluster runs inside a namespace of the underlying k8s cluster. It's cheaper than creating separate full-blown clusters and it offers better multi-tenancy and isolation than regular namespaces.

## Prerequisites
- Kubernetes 1.18+
- Helm 3+

## Get Helm Repository Info

```
helm repo add loft-sh https://charts.loft.sh
helm repo update
```
See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation.

## Install Helm Chart

```
helm upgrade [RELEASE_NAME] loft-sh/vcluster -n [RELEASE_NAMESPACE] --create-namespace --install
```

See [vcluster docs](https://vcluster.com/docs) for configuration options.

See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation.

## Connect to the vcluster

In order to connect to the installed vcluster, please install [vcluster cli](https://www.vcluster.com/docs/getting-started/setup) and run:
```
vcluster connect [RELEASE_NAME] -n [RELEASE_NAMESPACE]
```

## Uninstall Helm Chart

```
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation.

### Why Virtual Kubernetes Clusters?

- **Cluster Scoped Resources**: much more powerful than simple namespaces (virtual clusters allow users to use CRDs, namespaces, cluster roles etc.)
- **Ease of Use**: usable in any Kubernetes cluster and created in seconds either via a single command or [cluster-api](https://github.com/loft-sh/cluster-api-provider-vcluster)
- **Cost Efficient**: much cheaper and efficient than "real" clusters (single pod and shared resources just like for namespaces)
- **Lightweight**: built upon the ultra-fast k3s distribution with minimal overhead per virtual cluster (other distributions work as well)
- **Strict isolation**: complete separate Kubernetes control plane and access point for each vcluster while still being able to share certain services of the underlying host cluster
- **Cluster Wide Permissions**: allow users to install apps which require cluster-wide permissions while being limited to actually just one namespace within the host cluster
- **Great for Testing**: allow you to test different Kubernetes versions inside a single host cluster which may have a different version than the virtual clusters

Learn more on [www.vcluster.com](https://vcluster.com).

![vcluster Intro](https://github.com/loft-sh/vcluster/raw/main/docs/static/media/vcluster-comparison.png)

Learn more in the [documentation](https://vcluster.com/docs/what-are-virtual-clusters).
10 changes: 10 additions & 0 deletions charts/vcluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Thank you for installing vcluster.

Your vcluster is named {{ .Release.Name }} in namespace {{ .Release.Namespace }}.

To connect to the vcluster, use vcluster CLI (https://www.vcluster.com/docs/getting-started/setup):
$ vcluster connect {{ .Release.Name }} -n {{ .Release.Namespace }}
$ vcluster connect {{ .Release.Name }} -n {{ .Release.Namespace }} -- kubectl get ns


For more information, please take a look at the vcluster docs at https://www.vcluster.com/docs
168 changes: 168 additions & 0 deletions charts/vcluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "vcluster.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Whether the ingressclasses syncer should be enabled
*/}}
{{- define "vcluster.syncIngressclassesEnabled" -}}
{{- if or (.Values.sync.ingressclasses).enabled (and .Values.sync.ingresses.enabled (not .Values.sync.ingressclasses)) -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{/*
Whether to create a cluster role or not
*/}}
{{- define "vcluster.createClusterRole" -}}
{{- if or (not (empty (include "vcluster.serviceMapping.fromHost" . ))) (not (empty (include "vcluster.plugin.clusterRoleExtraRules" . ))) (not (empty (include "vcluster.generic.clusterRoleExtraRules" . ))) .Values.rbac.clusterRole.create .Values.sync.hoststorageclasses.enabled (index ((index .Values.sync "legacy-storageclasses") | default (dict "enabled" false)) "enabled") (include "vcluster.syncIngressclassesEnabled" . ) .Values.sync.nodes.enabled .Values.sync.persistentvolumes.enabled .Values.sync.storageclasses.enabled .Values.sync.priorityclasses.enabled .Values.sync.volumesnapshots.enabled .Values.proxy.metricsServer.nodes.enabled .Values.multiNamespaceMode.enabled -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{- define "vcluster.clusterRoleName" -}}
{{- printf "vc-%s-v-%s" .Release.Name .Release.Namespace | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "vcluster.clusterRoleNameMultinamespace" -}}
{{- printf "vc-mn-%s-v-%s" .Release.Name .Release.Namespace | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "vcluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Get
*/}}
{{- $}}
{{- define "vcluster.admin.accessKey" -}}
{{- now | unixEpoch | toString | trunc 8 | sha256sum -}}
{{- end -}}

{{/*
Syncer flags for enabling/disabling controllers
Prints only the flags that modify the defaults:
- when default controller has enabled: false => `- "--sync=-controller`
- when non-default controller has enabled: true => `- "--sync=controller`
*/}}
{{- define "vcluster.syncer.syncArgs" -}}
{{- $defaultEnabled := list "services" "configmaps" "secrets" "endpoints" "pods" "events" "persistentvolumeclaims" "fake-nodes" "fake-persistentvolumes" -}}
{{- if and (hasKey .Values.sync.nodes "enableScheduler") .Values.sync.nodes.enableScheduler -}}
{{- $defaultEnabled = concat $defaultEnabled (list "csinodes" "csidrivers" "csistoragecapacities" ) -}}
{{- end -}}
{{- range $key, $val := .Values.sync }}
{{- if and (has $key $defaultEnabled) (not $val.enabled) }}
- --sync=-{{ $key }}
{{- else if and (not (has $key $defaultEnabled)) ($val.enabled)}}
{{- if eq $key "legacy-storageclasses" }}
- --sync=hoststorageclasses
{{- else }}
- --sync={{ $key }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if not (include "vcluster.syncIngressclassesEnabled" . ) }}
- --sync=-ingressclasses
{{- end -}}
{{- end -}}

{{/*
Cluster role rules defined by plugins
*/}}
{{- define "vcluster.plugin.clusterRoleExtraRules" -}}
{{- range $key, $container := .Values.plugin }}
{{- if $container.rbac }}
{{- if $container.rbac.clusterRole }}
{{- if $container.rbac.clusterRole.extraRules }}
{{- range $ruleIndex, $rule := $container.rbac.clusterRole.extraRules }}
- {{ toJson $rule }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Cluster role rules defined in generic syncer
*/}}
{{- define "vcluster.generic.clusterRoleExtraRules" -}}
{{- if .Values.sync.generic.clusterRole }}
{{- if .Values.sync.generic.clusterRole.extraRules}}
{{- range $ruleIndex, $rule := .Values.sync.generic.clusterRole.extraRules }}
- {{ toJson $rule }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Role rules defined by plugins
*/}}
{{- define "vcluster.plugin.roleExtraRules" -}}
{{- range $key, $container := .Values.plugin }}
{{- if $container.rbac }}
{{- if $container.rbac.role }}
{{- if $container.rbac.role.extraRules }}
{{- range $ruleIndex, $rule := $container.rbac.role.extraRules }}
- {{ toJson $rule }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Role rules defined in generic syncer
*/}}
{{- define "vcluster.generic.roleExtraRules" -}}
{{- if .Values.sync.generic.role }}
{{- if .Values.sync.generic.role.extraRules}}
{{- range $ruleIndex, $rule := .Values.sync.generic.role.extraRules }}
- {{ toJson $rule }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Virtual cluster service mapping
*/}}
{{- define "vcluster.serviceMapping.fromVirtual" -}}
{{- range $key, $value := .Values.mapServices.fromVirtual }}
- '--map-virtual-service={{ $value.from }}={{ $value.to }}'
{{- end }}
{{- end -}}

{{/*
Host cluster service mapping
*/}}
{{- define "vcluster.serviceMapping.fromHost" -}}
{{- range $key, $value := .Values.mapServices.fromHost }}
- '--map-host-service={{ $value.from }}={{ $value.to }}'
{{- end }}
{{- end -}}
29 changes: 29 additions & 0 deletions charts/vcluster/templates/_k3s_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Returns the desired workload kind (StatefulSet / Deployment) for k3s
*/}}
{{- define "vcluster.k3s.workloadKind" -}}
{{- ternary "Deployment" "StatefulSet" (.Values.enableHA) -}}
{{- end -}}

{{/*
Returns the name of the secret containing the k3s tokens.
*/}}
{{- define "vcluster.k3s.tokenSecretName" -}}
{{- with .Values.serverToken.secretKeyRef.name -}}
{{- . -}}
{{- else -}}
{{- printf "%s-tokens" .Release.Name -}}
{{- end -}}
{{- end -}}

{{/*
Returns the secret key name containing the k3s server token.
*/}}
{{- define "vcluster.k3s.serverTokenKey" -}}
{{- with .Values.serverToken.secretKeyRef.key -}}
{{- . -}}
{{- else -}}
{{- "server-token" -}}
{{- end -}}
{{- end -}}
Loading
Loading