Skip to content

Commit

Permalink
Add hub-manager-robot chart
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Aug 22, 2024
1 parent 5171706 commit ae1137f
Show file tree
Hide file tree
Showing 14 changed files with 447 additions and 0 deletions.
65 changes: 65 additions & 0 deletions apis/installer/v1alpha1/hub_cluster_robot_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
ResourceKindHubManagerRobot = "HubManagerRobot"
ResourceHubManagerRobot = "hubmanagerrobot"
ResourceHubManagerRobots = "hubmanagerrobots"
)

// HubManagerRobot defines the schama for HubManagerRobot.

// +genclient
// +genclient:skipVerbs=updateStatus
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=hubmanagerrobots,singular=hubmanagerrobot,categories={kubeops,appscode}
type HubManagerRobot struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec HubManagerRobotSpec `json:"spec,omitempty"`
}

// HubManagerRobotSpec is the schema for Identity Server values file
type HubManagerRobotSpec struct {
//+optional
NameOverride string `json:"nameOverride"`
//+optional
FullnameOverride string `json:"fullnameOverride"`
// +optional
KubeconfigSecretName string `json:"kubeconfigSecretName"`
// +optional
AddonManagerNamespace string `json:"addonManagerNamespace"`
Kubectl DockerImage `json:"kubectl"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// HubManagerRobotList is a list of HubManagerRobots
type HubManagerRobotList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of HubManagerRobot CRD objects
Items []HubManagerRobot `json:"items,omitempty"`
}
2 changes: 2 additions & 0 deletions apis/installer/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ClusterManagerHubList{},
&ClusterManagerSpoke{},
&ClusterManagerSpokeList{},
&HubManagerRobot{},
&HubManagerRobotList{},
)

scheme.AddKnownTypes(SchemeGroupVersion,
Expand Down
74 changes: 74 additions & 0 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions charts/hub-cluster-robot/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
description: Hub Cluster Robot
name: hub-cluster-robot
version: v2024.8.9
appVersion: v0.0.1
home: https://github.com/kluster-manager/cluster-auth
icon: https://cdn.appscode.com/images/products/searchlight/icons/android-icon-192x192.png
sources:
- https://github.com/kluster-manager/cluster-auth
maintainers:
- name: appscode
email: [email protected]
68 changes: 68 additions & 0 deletions charts/hub-cluster-robot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Hub Cluster Robot

[Hub Cluster Robot](https://github.com/kluster-manager) - Hub Cluster Robot

## TL;DR;

```bash
$ helm repo add appscode https://charts.appscode.com/stable
$ helm repo update
$ helm search repo appscode/hub-cluster-robot --version=v2024.8.9
$ helm upgrade -i hub-cluster-robot appscode/hub-cluster-robot -n open-cluster-management --create-namespace --version=v2024.8.9
```

## Introduction

This chart deploys a Hub Cluster Robot on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.21+

## Installing the Chart

To install/upgrade the chart with the release name `hub-cluster-robot`:

```bash
$ helm upgrade -i hub-cluster-robot appscode/hub-cluster-robot -n open-cluster-management --create-namespace --version=v2024.8.9
```

The command deploys a Hub Cluster Robot on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall the `hub-cluster-robot`:

```bash
$ helm uninstall hub-cluster-robot -n open-cluster-management
```

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

## Configuration

The following table lists the configurable parameters of the `hub-cluster-robot` chart and their default values.

| Parameter | Description | Default |
|-----------------------|-------------|----------------------------------------------------|
| nameOverride | | <code>""</code> |
| fullnameOverride | | <code>""</code> |
| kubeconfigSecretName | | <code>""</code> |
| addonManagerNamespace | | <code>open-cluster-management-cluster-auth</code> |
| kubectl.image | | <code>ghcr.io/appscode/kubectl-nonroot:1.25</code> |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example:

```bash
$ helm upgrade -i hub-cluster-robot appscode/hub-cluster-robot -n open-cluster-management --create-namespace --version=v2024.8.9 --set addonManagerNamespace=open-cluster-management-cluster-auth
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
installing the chart. For example:

```bash
$ helm upgrade -i hub-cluster-robot appscode/hub-cluster-robot -n open-cluster-management --create-namespace --version=v2024.8.9 --values values.yaml
```
11 changes: 11 additions & 0 deletions charts/hub-cluster-robot/common/rbac/cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: open-cluster-management:hub-cluster-robot:cluster-auth
rules:
- apiGroups: [""]
resources: ["secrets", "serviceaccounts"]
verbs: ["get", "list", "watch"]
- apiGroups: [ "authentication.k8s.appscode.com" ]
resources: [ "*" ]
verbs: [ "*" ]
13 changes: 13 additions & 0 deletions charts/hub-cluster-robot/common/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: open-cluster-management:hub-cluster-robot:cluster-auth
namespace: open-cluster-management-cluster-auth
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: open-cluster-management:hub-cluster-robot
subjects:
- kind: ServiceAccount
name: hub-cluster-robot
namespace: {{ .Release.Namespace }}
5 changes: 5 additions & 0 deletions charts/hub-cluster-robot/common/rbac/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: hub-cluster-robot
namespace: {{ .Release.Namespace }}
18 changes: 18 additions & 0 deletions charts/hub-cluster-robot/doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project:
name: Hub Cluster Robot
shortName: Hub Cluster Robot
url: https://github.com/kluster-manager
description: Hub Cluster Robot
app: a Hub Cluster Robot
repository:
url: https://charts.appscode.com/stable
name: appscode
chart:
name: hub-cluster-robot
values: -- generate from values file --
valuesExample: -- generate from values file --
prerequisites:
- Kubernetes 1.21+
release:
name: hub-cluster-robot
namespace: open-cluster-management
69 changes: 69 additions & 0 deletions charts/hub-cluster-robot/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "hub-cluster-robot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
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 "hub-cluster-robot.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 }}

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

{{/*
Common labels
*/}}
{{- define "hub-cluster-robot.labels" -}}
helm.sh/chart: {{ include "hub-cluster-robot.chart" . }}
{{ include "hub-cluster-robot.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "hub-cluster-robot.selectorLabels" -}}
app.kubernetes.io/name: {{ include "hub-cluster-robot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "hub-cluster-robot.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "hub-cluster-robot.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Addon manager namespace
*/}}
{{- define "hub-cluster-robot.namespace" -}}
{{ ternary .Release.Namespace (required "A valid .Values.addonManagerNamespace is required!" .Values.addonManagerNamespace) (empty .Values.kubeconfigSecretName) }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/hub-cluster-robot/templates/k8s/addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if not .Values.kubeconfigSecretName }}

{{- $restpl := $.Files.Get "common/rbac/service_account.yaml" }}
{{ tpl $restpl $ }}
---
{{- $restpl := $.Files.Get "common/rbac/cluster_role.yaml" }}
{{ tpl $restpl $ }}
---
{{- $restpl := $.Files.Get "common/rbac/role_binding.yaml" }}
{{ tpl $restpl $ }}

{{- end }}
Loading

0 comments on commit ae1137f

Please sign in to comment.