Skip to content
Open
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
71 changes: 45 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ We recommend running this command as an unprivileged user, that is inside the [d
- [External Mailserver](#external-mailserver)
- [Secrets Management](#secrets-management)
- [Certificate Management](#certificate-management)
- [Profiles](#profiles)
- [Remove playground](#remove-playground)
- [Running on Windows or Mac](#running-on-windows-or-mac)
- [Mac and Windows WSL](#mac-and-windows-wsl)
Expand Down Expand Up @@ -289,32 +290,33 @@ That is, if you pass a param via CLI, for example, it will overwrite the corresp

###### Application

| CLI | Config | Default | Type | Description |
|-----|--------|---------|------|-------------|
| `--config-file` | - | `''` | String | Config file path |
| `--config-map` | - | `''` | String | Config map name |
| `-d, --debug` | `application.debug` | - | Boolean | Enable debug mode |
| `-x, --trace` | `application.trace` | - | Boolean | Enable trace mode |
| `--output-config-file` | `application.outputConfigFile` | `false` | Boolean | Output configuration file |
| `-v, --version` | `application.versionInfoRequested` | `false` | Boolean | Display version and license info |
| `-h, --help` | `application.usageHelpRequested` | `false` | Boolean | Display help message |
| `--remote` | `application.remote` | `false` | Boolean | Expose services as LoadBalancers |
| `--insecure` | `application.insecure` | `false` | Boolean | Sets insecure-mode in cURL which skips cert validation |
| `--openshift` | `application.openshift` | `false` | Boolean | When set, openshift specific resources and configurations are applied |
| `--username` | `application.username` | `'admin'` | String | Set initial admin username |
| `--password` | `application.password` | `'admin'` | String | Set initial admin passwords |
| `-y, --yes` | `application.yes` | `false` | Boolean | Skip confirmation |
| `--name-prefix` | `application.namePrefix` | `''` | String | Set name-prefix for repos, jobs, namespaces |
| `--destroy` | `application.destroy` | `false` | Boolean | Unroll playground |
| `--pod-resources` | `application.podResources` | `false` | Boolean | Write kubernetes resource requests and limits on each pod |
| `--git-name` | `application.gitName` | `'Cloudogu'` | String | Sets git author and committer name used for initial commits |
| `--git-email` | `application.gitEmail` | `'hello@cloudogu.com'` | String | Sets git author and committer email used for initial commits |
| `--base-url` | `application.baseUrl` | `''` | String | The external base url (TLD) for all tools |
| `--url-separator-hyphen` | `application.urlSeparatorHyphen` | `false` | Boolean | Use hyphens instead of dots to separate application name from base-url |
| `--mirror-repos` | `application.mirrorRepos` | `false` | Boolean | Changes the sources of deployed tools so they work in air-gapped environments |
| `--skip-crds` | `application.skipCrds` | `false` | Boolean | Skip installation of CRDs |
| `--namespace-isolation` | `application.namespaceIsolation` | `false` | Boolean | Configure tools to work with given namespaces only |
| `--netpols` | `application.netpols` | `false` | Boolean | Sets Network Policies |
| CLI | Config | Default | Type | Description |
|--------------------------|------------------------------------|---------|----------|-------------------------------------------------------------------------------|
| `--config-file` | - | `''` | String | Config file path |
| `--config-map` | - | `''` | String | Config map name |
| `-d, --debug` | `application.debug` | - | Boolean | Enable debug mode |
| `-x, --trace` | `application.trace` | - | Boolean | Enable trace mode |
| `--output-config-file` | `application.outputConfigFile` | `false` | Boolean | Output configuration file |
| `-v, --version` | `application.versionInfoRequested` | `false` | Boolean | Display version and license info |
| `-h, --help` | `application.usageHelpRequested` | `false` | Boolean | Display help message |
| `--remote` | `application.remote` | `false` | Boolean | Expose services as LoadBalancers |
| `--insecure` | `application.insecure` | `false` | Boolean | Sets insecure-mode in cURL which skips cert validation |
| `--openshift` | `application.openshift` | `false` | Boolean | When set, openshift specific resources and configurations are applied |
| `--username` | `application.username` | `'admin'` | String | Set initial admin username |
| `--password` | `application.password` | `'admin'` | String | Set initial admin passwords |
| `-y, --yes` | `application.yes` | `false` | Boolean | Skip confirmation |
| `--name-prefix` | `application.namePrefix` | `''` | String | Set name-prefix for repos, jobs, namespaces |
| `--destroy` | `application.destroy` | `false` | Boolean | Unroll playground |
| `--pod-resources` | `application.podResources` | `false` | Boolean | Write kubernetes resource requests and limits on each pod |
| `--git-name` | `application.gitName` | `'Cloudogu'` | String | Sets git author and committer name used for initial commits |
| `--git-email` | `application.gitEmail` | `'hello@cloudogu.com'` | String | Sets git author and committer email used for initial commits |
| `--base-url` | `application.baseUrl` | `''` | String | The external base url (TLD) for all tools |
| `--url-separator-hyphen` | `application.urlSeparatorHyphen` | `false` | Boolean | Use hyphens instead of dots to separate application name from base-url |
| `--mirror-repos` | `application.mirrorRepos` | `false` | Boolean | Changes the sources of deployed tools so they work in air-gapped environments |
| `--skip-crds` | `application.skipCrds` | `false` | Boolean | Skip installation of CRDs |
| `--namespace-isolation` | `application.namespaceIsolation` | `false` | Boolean | Configure tools to work with given namespaces only |
| `--netpols` | `application.netpols` | `false` | Boolean | Sets Network Policies |
| `-p, --profiles` | `application.profile` | `''` | String | Sets a profile for pre-defined parameter |


###### Registry
Expand Down Expand Up @@ -882,6 +884,23 @@ i.e.
```
--cert-manager-image someRegistry/cert-manager-controller:latest
```
#### Profiles
GOP includes some pre-defined profiles for easy usage.
e.g. set `--profile=full` to start GOP with all features enabled.


Current existing profiles for argocd in non-operator mode:
- `full` - all features enabled
- `small` - starts only with ArgoCD and SCM-Manger
- `content-examples` - starts with ArgoCD, Jenkins, SCM-Manager and Petclinic

Follow profils for ArgoCD in Operator mode which has to be installed first:
- `operator-full` - all features enabled
- `operator-small` - starts only with ArgoCD and SCM-Manger
- `operator-petclinic` - starts with ArgoCD, Jenkins, SCM-Manager and Petclinic
- `operator-mandant` - starts mandant/tenant example


### Remove playground

For k3d, you can just `k3d cluster delete gitops-playground`. This will delete the whole cluster.
Expand Down
41 changes: 34 additions & 7 deletions src/main/groovy/com/cloudogu/gitops/cli/GitopsPlaygroundCli.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GitopsPlaygroundCli {
new CommandLine(cliParams).execute(args)
return ReturnCode.SUCCESS
}

def version = createVersionOutput()
if (cliParams.application.versionInfoRequested) {
println version
Expand All @@ -72,7 +72,7 @@ class GitopsPlaygroundCli {
println(config.toYaml(false))
return ReturnCode.SUCCESS
}

// Set internal values in config after help/version/output because these should work without connecting to k8s
// eg a simple docker run .. --help should not fail with connection refused
config = applicationConfigurator.initConfig(config)
Expand Down Expand Up @@ -186,10 +186,15 @@ class GitopsPlaygroundCli {
def cliParams = new Config()
new CommandLine(cliParams).parseArgs(args)

// first evaluate profile for setting predefined values e.g. examples, if applicable
Config profileConfig = extractProfile(cliParams)



String configFilePath = cliParams.application.configFile
String configMapName = cliParams.application.configMap
Boolean contentExamples = cliParams.content.examples
Boolean multiTenancyExamples = cliParams.content.multitenancyExamples
Boolean contentExamples = cliParams.content.examples || profileConfig.content.examples
Boolean multiTenancyExamples = cliParams.content.multitenancyExamples || profileConfig.content.multitenancyExamples

Map configFile = [:]
Map configMap = [:]
Expand Down Expand Up @@ -219,20 +224,21 @@ class GitopsPlaygroundCli {
multiTenancyContentExamplesFile = validateConfig(new File(multiTenancyContentExamplesConfigPath).text)
}


// Last one takes precedence
def configPrecedence = [configMap, configFile, contentExamplesFile, multiTenancyContentExamplesFile]
def configPrecedence = [profileConfig.toMap(), configMap, configFile, contentExamplesFile, multiTenancyContentExamplesFile]
Map mergedConfigs = [:]
configPrecedence.each {
deepMerge(it, mergedConfigs)
}

// DeepMerge with default Config values to keep the default values defined in Config.groovy
mergedConfigs = deepMerge(mergedConfigs,new Config().toMap())
mergedConfigs = deepMerge(mergedConfigs, new Config().toMap())

log.debug("Writing CLI params into config")
Config mergedConfig = Config.fromMap(mergedConfigs)
new CommandLine(mergedConfig).parseArgs(args)

return mergedConfig
}

Expand Down Expand Up @@ -274,4 +280,25 @@ class GitopsPlaygroundCli {
}
}
}

private static Config extractProfile(Config newConfig) {

String profile = newConfig.application.profile

Config profileConfig = new Config()
if (profile) {
String profileName = "src/main/resources/application-${profile}.yaml"
log.debug("Loading profile '${profileName}'")
def file
try {
file = new File(profileName)

} catch (Exception e) {
throw new RuntimeException("Profile '${profileName}' does not exist.")
}
Map profileFile = validateConfig(file.text)
profileConfig = Config.fromMap(profileFile)
}
return profileConfig
}
}
3 changes: 3 additions & 0 deletions src/main/groovy/com/cloudogu/gitops/config/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ class Config {
@JsonPropertyDescription(CLUSTER_ADMIN_DESCRIPTION)
Boolean clusterAdmin = false

@Option(names = ["-p", "--profile"], description = APPLICATION_PROFIL)
String profile

static class NamespaceSchema {
LinkedHashSet<String> dedicatedNamespaces = new LinkedHashSet<>()
LinkedHashSet<String> tenantNamespaces = new LinkedHashSet<>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ interface ConfigConstants {
String NETPOLS_DESCRIPTION = 'Sets Network Policies'
String CLUSTER_ADMIN_DESCRIPTION = 'Binds ArgoCD controllers to cluster-admin ClusterRole'
String OPENSHIFT_DESCRIPTION = 'When set, openshift specific resources and configurations are applied'
String APPLICATION_PROFIL = 'Use predefined profile (full, only-argocd, operator-mandants aso.)'

// group metrics
String MONITORING_DESCRIPTION = 'Config parameters for the Monitoring system (prometheus)'
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/application-content-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://localhost
features:
argocd:
active: true
operator: false
ingressNginx:
active: true
content:
examples: true
jenkins:
active: true
registry:
active: true
24 changes: 24 additions & 0 deletions src/main/resources/application-full-prefix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://my-prefix.localhost
namePrefix: my-prefix
features:
certManager:
active: true
argocd:
active: true
operator: false
ingressNginx:
active: true
monitoring:
active: true
secrets:
vault:
mode: "dev"
content:
examples: true
jenkins:
active: true
registry:
active: true
23 changes: 23 additions & 0 deletions src/main/resources/application-full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://localhost
features:
certManager:
active: true
argocd:
active: true
operator: false
ingressNginx:
active: true
monitoring:
active: true
secrets:
vault:
mode: "dev"
content:
examples: true
jenkins:
active: true
registry:
active: true
25 changes: 25 additions & 0 deletions src/main/resources/application-operator-full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://localhost
insecure: true
features:
certManager:
active: true
argocd:
active: true
operator: true
resourceInclusionsCluster: "https://10.43.0.1:443"
ingressNginx:
active: true
monitoring:
active: true
secrets:
vault:
mode: "dev"
content:
examples: true
jenkins:
active: true
registry:
active: true
4 changes: 4 additions & 0 deletions src/main/resources/application-operator-mandants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
content:
multitenancyExamples: true

16 changes: 16 additions & 0 deletions src/main/resources/application-operator-petclinic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://localhost
insecure: true
features:
argocd:
active: true
operator: true
resourceInclusionsCluster: "https://10.43.0.1:443"
content:
examples: true
jenkins:
active: true
registry:
active: true
9 changes: 9 additions & 0 deletions src/main/resources/application-operator-small.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://localhost
features:
argocd:
active: true
operator:
resourceInclusionsCluster: "https://10.43.0.1:443"
8 changes: 8 additions & 0 deletions src/main/resources/application-small.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
application:
"yes": true
baseUrl: http://localhost
features:
argocd:
active: true
operator: false
Loading