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

Generate CE/EE example YAMLs separately #11129

Merged
merged 2 commits into from Oct 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion codegen/example-yaml/main.go
Expand Up @@ -33,6 +33,7 @@ import (
appskubermaticv1 "k8c.io/kubermatic/v2/pkg/apis/apps.kubermatic/v1"
kubermaticv1 "k8c.io/kubermatic/v2/pkg/apis/kubermatic/v1"
"k8c.io/kubermatic/v2/pkg/defaulting"
"k8c.io/kubermatic/v2/pkg/util/edition"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -48,6 +49,9 @@ func main() {
log.Fatal("Usage: go run main.go SRC_ROOT TARGET")
}

ed := edition.KubermaticEdition
log.Printf("Generating for %s", ed)

root := flag.Arg(0)
target := flag.Arg(1)

Expand Down Expand Up @@ -90,7 +94,7 @@ func main() {
for name, data := range examples {
log.Printf("Creating example YAML for %s resources...", name)

filename := filepath.Join(target, fmt.Sprintf("zz_generated.%s.yaml", name))
filename := filepath.Join(target, fmt.Sprintf("zz_generated.%s.%s.yaml", name, strings.ToLower(ed.ShortString())))

f, err := os.Create(filename)
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions docs/docs_ce.go
@@ -0,0 +1,27 @@
//go:build !ee

/*
Copyright 2022 The Kubermatic Kubernetes Platform 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 docs

import _ "embed"

//go:embed zz_generated.kubermaticConfiguration.ce.yaml
var ExampleKubermaticConfiguration string

//go:embed zz_generated.seed.ce.yaml
var ExampleSeedConfiguration string
8 changes: 5 additions & 3 deletions docs/docs.go → docs/docs_ee.go
@@ -1,5 +1,7 @@
//go:build ee

/*
Copyright 2021 The Kubermatic Kubernetes Platform contributors.
Copyright 2022 The Kubermatic Kubernetes Platform contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,8 +20,8 @@ package docs

import _ "embed"

//go:embed zz_generated.kubermaticConfiguration.yaml
//go:embed zz_generated.kubermaticConfiguration.ee.yaml
var ExampleKubermaticConfiguration string

//go:embed zz_generated.seed.yaml
//go:embed zz_generated.seed.ee.yaml
var ExampleSeedConfiguration string
133 changes: 133 additions & 0 deletions docs/zz_generated.applicationDefinition.ee.yaml
@@ -0,0 +1,133 @@
apiVersion: apps.kubermatic.k8c.io/v1
kind: ApplicationDefinitions
metadata:
name: <<appdef-name>>
spec:
# Description of the application. what is its purpose
description: ""
# Method used to install the application
method: helm
# Available version for this application
versions:
- # Template defines how application is installed (source provenance, Method...)
template:
# Defined how the source of the application (e.g Helm chart) is retrieved.
# Exactly one type of source must be defined.
source:
# Install application from a Git repository
git:
# Credentials are optional and holds the git credentials
credentials:
# Authentication method. Either password or token or ssh-key.
# if method is password then username and password must be defined.
# if method is token then token must be defined.
# if method is ssh-key then ssh-key must be defined.
method: password ||token || ssh-key
# Password holds the ref and key in the secret for the Password credential.
# The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
password:
# The key of the secret to select from. Must be a valid secret key.
key: pass
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# SSHKey holds the ref and key in the secret for the SshKey credential.
# The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
sshKey:
# The key of the secret to select from. Must be a valid secret key.
key: private-key
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# Token holds the ref and key in the secret for the token credential.
# The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
token:
# The key of the secret to select from. Must be a valid secret key.
key: token
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# Username holds the ref and key in the secret for the username credential.
# The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
username:
# The key of the secret to select from. Must be a valid secret key.
key: user
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# Path of the "source" in the repository. default is repository root
path: charts/apache
# Git reference to checkout.
# For large repositories, we recommend to either use Tag, Branch or Branch+Commit. This allows a shallow clone, which dramatically speeds up performance
ref:
# Branch to checkout. Only the last commit of the branch will be checkout in order to reduce the amount of data to download.
branch: master
# Commit SHA in a Branch to checkout.

# It must be used in conjunction with branch field.
commit: 8061ceb738db42fe82b4c305b7aa5459d926d03e
# Tag to check out.
# It can not be used in conjunction with commit or branch.
tag: v1.2.3
# URL to the repository. Can be HTTP(s) (e.g. https://example.com/myrepo) or SSH (e.g. git://example.com[:port]/path/to/repo.git/)
remote: https://git.example.com/repo || git@example.com/repo
# Install Application from a Helm repository
helm:
# Name of the Chart.
chartName: my-app
# Version of the Chart.
chartVersion: v13.9.0
# Credentials are optional and hold the ref to the secret with helm credentials.
# Either username / Password or registryConfigFile can be defined.
credentials:
# Password holds the ref and key in the secret for the Password credential.
# The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
password:
# The key of the secret to select from. Must be a valid secret key.
key: pass
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# RegistryConfigFile holds the ref and key in the secret for the registry credential file. The value is dockercfg
# file that follows the same format rules as ~/.docker/config.json
# The The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
registryConfigFile:
# The key of the secret to select from. Must be a valid secret key.
key: .dockerconfigjson
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# Username holds the ref and key in the secret for the username credential.
# The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
# The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to helm or git
username:
# The key of the secret to select from. Must be a valid secret key.
key: user
# Name of the referent.
# More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
name: <<secret-name>>
# Specify whether the Secret or its key must be defined
optional: false
# URl of the helm repository.
# It can be an HTTP(s) repository (e.g. https://localhost/myrepo) or on OCI repository (e.g. oci://localhost:5000/myrepo).
url: https://charts.example.com || oci://localhost:5000/myrepo
# Version of the application (e.g. v1.2.3)
version: v1.2.3
31 changes: 31 additions & 0 deletions docs/zz_generated.applicationInstallation.ee.yaml
@@ -0,0 +1,31 @@
apiVersion: apps.kubermatic.k8c.io/v1
kind: ApplicationInstallations
metadata:
name: <<appInstallation-name>>
spec:
# ApplicationRef is a reference to identify which Application should be deployed
applicationRef:
# Name of the Application.
# Should be a valid lowercase RFC1123 domain name
name: apache
# Version of the Application. Must be a valid SemVer version
version: 1.2.3
# Namespace describe the desired state of the namespace where application will be created.
namespace:
# Annotations of the namespace
# More info: http://kubernetes.io/docs/user-guide/annotations
annotations:
project-code: azerty
# Create defines whether the namespace should be created if it does not exist. Defaults to true
create: true
# Labels of the namespace
# More info: http://kubernetes.io/docs/user-guide/labels
labels:
env: dev
# Name is the namespace to deploy the Application into.
# Should be a valid lowercase RFC1123 domain name
name: my-namespace
# Values describe overrides for manifest-rendering. It's a free yaml field.
values:
commonLabels:
owner: somebody