Table of Contents
This document will describe all the CRDs captain use and introduced.
HelmRequest is a CRD that defines how to install a helm charts. It's kind of like the helm cli, you can set various options when install a helm charts. But with HelmRequest, it easier to persistent the configuration, and because we now have a controller, which can ensure to successfully install the chats by retrying automatically. This can solve a lot of problems when using helm chats in helm 2, such as
- Some pre-existing resource cause the
helm install
to fail - CRD with
crd-install
hooks not deleted after delete a helm chart, which cause the previous problem again - arbitrary errors which can be resolved by retry
- ...
An example HelmRequest looks like this(after setting some defaults):
apiVersion: app.alauda.io/v1
kind: HelmRequest
metadata:
finalizers:
- captain.alauda.io
name: nginx-ingress
namespace: default
spec:
chart: stable/nginx-ingress
namespace: default
releaseName: nginx-ingress
clusterName: ""
dependencies:
- nginx
installToAllClusters: false
values:
env: prod
global:
namespace: h8
status:
lastSpecHash: "15900028196316601597"
notes: "<helm charts notes>"
phase: Synced
The chart name, format as <repo-name>/<chart-name>
, this is the only force required field in HelmRequest.Spec
The chart's version. It's optional, just likes helm cli.
If not set, default to HelmRequest.Name. In Helm2, if you not set the release name, helm will create a random string for you(which looks like docker container names), which is very unreasonable.
Also, since Release is namespace scoped CRD resource, it's name is not required to be global unique anymore
If not set, default to HelmRequest.Namespace
If not set, default to "", which means this chart will be installed to the current. Otherwise, the charts will be installed to the specific cluster
Default to false, and it override spec.clusterName
. If set to true
, means this charts will be installed to all the clusters, not only the existing ones,
even the ones added after this HelmRequest (informers will force rsync HelmRequest resource periodically, and captain will refresh cluster list, so just wait and see the magic happens!)
A list of HelmRequests in the current namespace that need to be synced before this one.
The same format and effect as in helm's values.yaml
file.
List of Secrets, ConfigMaps from which to take values. If both spec.values
and spec.valuesFrom
is set, the spec.values
will override.
spec:
# chart: ...
valuesFrom:
- configMapKeyRef:
# Name of the config map, must be in the same namespace as the
# HelmRequest
name: default-values # mandatory
# Key in the config map to get the values from
key: values.yaml # optional; defaults to values.yaml
# If set to true successful retrieval of the values file is no
# longer mandatory
optional: false # optional; defaults to false
- secretKeyRef:
# Name of the secret, must be in the same namespace as the
# HelmRequest
name: default-values # mandatory
# Key in the secret to get thre values from
key: values.yaml # optional; defaults to values.yaml
# If set to true successful retrieval of the values file is no
# longer mandatory
optional: true # optional; defaults to false
Centralized configuration can be a great helper to manage multiple HelmRequest resources.
Helmrequest now supports version v1 and has added new fields.
The chart's source. It's optional, this will indicate the source of the current chart, which will be an OCI or HTTP URL address.
If basic authentication is required, specify a secretname in the spec.source.oci
or spec.source.http
.
As shown in the following examples
# OCI type
apiVersion: app.alauda.io/v1
kind: HelmRequest
metadata:
name: test-oci
namespace: default
spec:
source:
oci:
repo: 192.168.26.40:60080/acp/chart-tomcat # oci repo address
secretRef: ociSecret # optional, if basic authentication is required, specify a secretname here.
values:
namespace: default
version: 9.2.9 # required, oci version
---
# HTTP type
apiVersion: app.alauda.io/v1
kind: HelmRequest
metadata:
name: test-http
namespace: default
spec:
source:
http:
url: https://alauda.github.io/captain-test-charts/wordpress-lookup-11.0.13.tgz
values: {}
ChartRepo
represents a helm repository, where helm client can retrieve and upload helm charts.
The definition is quite simple, For example, the most simplest ones is :
apiVersion: app.alauda.io/v1beta1
kind: ChartRepo
metadata:
name: stable
namespace: captain
spec:
url: https://kubernetes-charts.storage.googleapis.com
type: Chart
metadata.name
: the name of this repometadata.namespace
: Captain will only read ChartRepo resources from one namespace, default tocaptain
, and can be customized in helm values (.namespace
)spec.url
: the url of this repospec.type
: the type of this chartrepo. HereChart
means this is a normal helm chart repo. For more information, see the sections below
After created, we can use kubectl
to checkout the repo list
root@VM-16-12-ubuntu:/home/ubuntu# kubectl get ctr -n captain
NAME URL PHASE AGE
stable https://kubernetes-charts.storage.googleapis.com Synced 21m
The output is very similar to helm repo list
.
In addition to normal helm chart repo (http server), captain also supported following use cases:
- Pull charts manifests from vcs repo, eg: git/svn
- Shipped with a built in helm chart repo, so the user can use it out-of-box
ChartRepo support following type:
Chart
: helm chart repoGit/SVN
: refer to Git/SVN Support for more information.Local
: use the chartrepo shipped with captain. In this case,.spec.url
should be "", and captain will generate the repo url for you.
Of course ,many repos need auth support. Currently, ChartRepo
has support basic auth by specify
a secret resource in the spec:
apiVersion: app.alauda.io/v1beta1
kind: ChartRepo
metadata:
name: new
namespace: captain
spec:
url: <url>
secret:
name: new
spec.secret.name
: name of the secretspec.secret.namespace
: namespace of the secret, an optional field, default to the same namespace asChartRepo
Then, all you need is a secret which contains username
and password
data:
apiVersion: v1
data:
password: MndiNEUxaXlkUmo3
username: N0RPOVFvTHREeDFn
kind: Secret
metadata:
name: new
namespace: captain
type: Opaque
From version 0.9.2
, captain add a Chart
CRD to represents helm charts info. Here is an example chart
[root@ace-master-1 ~]# kubectl get charts.app.alauda.io -n alauda-system seq.stable
NAME VERSION APPVERSION AGE
seq.stable 1.0.2 5 7d
[root@ace-master-1 ~]# kubectl get charts.app.alauda.io -n alauda-system seq.stable -o yaml
apiVersion: app.alauda.io/v1beta1
kind: Chart
metadata:
creationTimestamp: "2019-09-17T05:58:19Z"
generation: 1
labels:
repo: stable
name: seq.stable
namespace: alauda-system
resourceVersion: "49110918"
selfLink: /apis/app.alauda.io/v1alpha1/namespaces/alauda-system/charts/seq.stable
uid: 260e2e49-d910-11e9-b3b1-525400488bfd
spec:
versions:
- apiVersion: v1
appVersion: "5"
created: "2019-09-17T05:28:13.665649241Z"
description: Seq is the easiest way for development teams to capture, search and
visualize structured log events! This page will walk you through the very quick
setup process.
digest: 8c64cdeb44d002cec4cda2abeaf7a3fa618da34aebdb7b789512400fd3543b82
home: https://getseq.net/
icon: https://avatars1.githubusercontent.com/u/5898109?s=200&v=4
keywords:
- seq
- structured
- logging
maintainers:
- email: [email protected]
name: nblumhardt
- email: [email protected]
name: KodrAus
- email: [email protected]
name: gertjvr
name: seq
sources:
- https://github.com/datalust/seq-tickets
urls:
- https://kubernetes-charts.storage.googleapis.com/seq-1.0.2.tgz
version: 1.0.2
- apiVersion: v1
appVersion: "5"
created: "2019-07-14T23:57:05.986935922Z"
description: Seq is the easiest way for development teams to capture, search and
visualize structured log events! This page will walk you through the very quick
setup process.
digest: 922009a14d60c136440d5ac9fdae8e5145d43b8ca3f46f24a34871b8f9cba875
home: https://getseq.net/
icon: https://avatars1.githubusercontent.com/u/5898109?s=200&v=4
keywords:
- seq
- structured
- logging
maintainers:
- email: [email protected]
name: nblumhardt
- email: [email protected]
name: KodrAus
- email: [email protected]
name: gertjvr
name: seq
sources:
- https://github.com/datalust/seq-tickets
urls:
- https://kubernetes-charts.storage.googleapis.com/seq-1.0.1.tgz
version: 1.0.1
A little explanation
- the name of this chart choose the format of
<chart-name>.<repo-name>
, because different repo can have chart with the same name .spec
contains list of chart versions, which contains all the metadata a chart version have
After a ChartRepo was created ,captain will start to sync the charts this repo have and create all the charts resources, mostly this will only take less than a minute. For now the charts resources only serves to api usage, captain still use helm's local cache to locate chart, but this will be soon changed.
Release CRD stores the release info of a helm charts, it has some differences compares to the Helm2 format:
- It's a CRD, not a special purpose ConfigMap or Secret
- No more name conflict between different namespaces
- It may lives in a different cluster with HelmRequest
Here is an example Release resource:
apiVersion: app.alauda.io/v1alpha1
kind: Release
metadata:
creationTimestamp: "2019-07-26T07:15:59Z"
generation: 2
labels:
modifiedAt: "1564125359"
name: nginx
owner: helm
status: deployed
version: "3"
name: nginx.v3
namespace: h8
resourceVersion: "27352526"
selfLink: /apis/app.alauda.io/v1alpha1/namespaces/h8/releases/nginx.v3
uid: 37fae69c-af75-11e9-b1c5-525400cb432d
spec:
chartData: H4sIAAAAAAAC/8RZbXOiShb+Kyk+OwngkLum6latGAGN4khiN/TWra1+YQDtBkpAxan8960GNS+azN47u3U/pCo2fU6f85znvND8UKZhiRkusXL3Q0mxCJU7JY2SdPclSaN1WBRKR4mzZjkuy7y4u7mJkjKuyDXNxM2qIuE6DcuwuDls/9IIKx2lyKo1DQvl7l9/SvCPjrIJ10WSpcqdol3fXmu/KR2FhQVdJ3nZLvfTq2bz1agVvaJZWq4zzsP1VRnj8qoqwuJqkKXfk2iK86syuyrKbB1elXF4kKTNw2qNpcpr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LuxItKNgyziwbuGSJlmrw5s3v7rrLkCSDrveL9cPH2/ubh9Xi85fb60Xb5wN5enqK/HNAoo2bTGZIZrO2i3Zibn41qOOOCcWup/LystVH3OUTeskPWhYDTFOGPPmM6YCpMi7B5vHx+Rr1m1l3+6Cwd+cQRpBmwPOE2adWj4ctCdR9a9kaNIdCzVdij2Nk9bKzHQo0ZqnlFjuMUmDcaVznGk0ueRKTzrn7/X5E26uFCiUY5wjc5r/3rIFH+Wx3TIbm6BP5ab1etm3+0WTAb5DDYYVUisTPTZ06KNRMJifNxlGKxjTymXaeJFagdPYEgEZI2LdQq/cow9lfAQAA//8jyZd28xAAAA==
name: nginx
version: 3
status:
Description: Upgrade complete
deleted: null
first_deployed: "2019-07-26T07:02:49Z"
last_deployed: "2019-07-26T07:15:59Z"
status: deployed
From the internal view, it also has some improvements compares to the old version:
- Use separated filed to store helm data
- Move some info the to
status
filed, which is more reasonable
Now you can use kubectl to get the releases and see there status directly:
[root@ake-master1 ~]# kubectl get rel --all-namespaces
NAMESPACE NAME STATUS AGE
h8 sh.helm.release.v1.nginx.v1 superseded 2d
h8 sh.helm.release.v1.nginx.v2 superseded 2d
h8 sh.helm.release.v1.nginx.v3 deployed 2d
[root@ake-master1 ~]#