Skip to content

Commit 5a79f46

Browse files
author
Thomas Michael
committed
add profiles and first test classes
1 parent 1217a6e commit 5a79f46

15 files changed

+400
-33
lines changed

README.md

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ We recommend running this command as an unprivileged user, that is inside the [d
7474
- [External Mailserver](#external-mailserver)
7575
- [Secrets Management](#secrets-management)
7676
- [Certificate Management](#certificate-management)
77+
- [Profiles](#profiles)
7778
- [Remove playground](#remove-playground)
7879
- [Running on Windows or Mac](#running-on-windows-or-mac)
7980
- [Mac and Windows WSL](#mac-and-windows-wsl)
@@ -289,32 +290,33 @@ That is, if you pass a param via CLI, for example, it will overwrite the corresp
289290

290291
###### Application
291292

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

319321

320322
###### Registry
@@ -882,6 +884,23 @@ i.e.
882884
```
883885
--cert-manager-image someRegistry/cert-manager-controller:latest
884886
```
887+
#### Profiles
888+
GOP includes some pre-defined profiles for easy usage.
889+
e.g. set `--profile=full` to start GOP with all features enabled.
890+
891+
892+
Current existing profiles for argocd in non-operator mode:
893+
- `full` - all features enabled
894+
- `small` - starts only with ArgoCD and SCM-Manger
895+
- `content-examples` - starts with ArgoCD, Jenkins, SCM-Manager and Petclinic
896+
897+
Follow profils for ArgoCD in Operator mode which has to be installed first:
898+
- `operator-full` - all features enabled
899+
- `operator-small` - starts only with ArgoCD and SCM-Manger
900+
- `operator-petclinic` - starts with ArgoCD, Jenkins, SCM-Manager and Petclinic
901+
- `operator-mandant` - starts mandant/tenant example
902+
903+
885904
### Remove playground
886905

887906
For k3d, you can just `k3d cluster delete gitops-playground`. This will delete the whole cluster.

src/main/groovy/com/cloudogu/gitops/cli/GitopsPlaygroundCli.groovy

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class GitopsPlaygroundCli {
5555
new CommandLine(cliParams).execute(args)
5656
return ReturnCode.SUCCESS
5757
}
58-
58+
5959
def version = createVersionOutput()
6060
if (cliParams.application.versionInfoRequested) {
6161
println version
@@ -72,7 +72,7 @@ class GitopsPlaygroundCli {
7272
println(config.toYaml(false))
7373
return ReturnCode.SUCCESS
7474
}
75-
75+
7676
// Set internal values in config after help/version/output because these should work without connecting to k8s
7777
// eg a simple docker run .. --help should not fail with connection refused
7878
config = applicationConfigurator.initConfig(config)
@@ -186,10 +186,15 @@ class GitopsPlaygroundCli {
186186
def cliParams = new Config()
187187
new CommandLine(cliParams).parseArgs(args)
188188

189+
// first evaluate profile for setting predefined values e.g. examples, if applicable
190+
Config profileConfig = extractProfile(cliParams)
191+
192+
193+
189194
String configFilePath = cliParams.application.configFile
190195
String configMapName = cliParams.application.configMap
191-
Boolean contentExamples = cliParams.content.examples
192-
Boolean multiTenancyExamples = cliParams.content.multitenancyExamples
196+
Boolean contentExamples = cliParams.content.examples || profileConfig.content.examples
197+
Boolean multiTenancyExamples = cliParams.content.multitenancyExamples || profileConfig.content.multitenancyExamples
193198

194199
Map configFile = [:]
195200
Map configMap = [:]
@@ -219,20 +224,21 @@ class GitopsPlaygroundCli {
219224
multiTenancyContentExamplesFile = validateConfig(new File(multiTenancyContentExamplesConfigPath).text)
220225
}
221226

227+
222228
// Last one takes precedence
223-
def configPrecedence = [configMap, configFile, contentExamplesFile, multiTenancyContentExamplesFile]
229+
def configPrecedence = [profileConfig.toMap(), configMap, configFile, contentExamplesFile, multiTenancyContentExamplesFile]
224230
Map mergedConfigs = [:]
225231
configPrecedence.each {
226232
deepMerge(it, mergedConfigs)
227233
}
228234

229235
// DeepMerge with default Config values to keep the default values defined in Config.groovy
230-
mergedConfigs = deepMerge(mergedConfigs,new Config().toMap())
236+
mergedConfigs = deepMerge(mergedConfigs, new Config().toMap())
231237

232238
log.debug("Writing CLI params into config")
233239
Config mergedConfig = Config.fromMap(mergedConfigs)
234240
new CommandLine(mergedConfig).parseArgs(args)
235-
241+
236242
return mergedConfig
237243
}
238244

@@ -274,4 +280,25 @@ class GitopsPlaygroundCli {
274280
}
275281
}
276282
}
283+
284+
private static Config extractProfile(Config newConfig) {
285+
286+
String profile = newConfig.application.profile
287+
288+
Config profileConfig = new Config()
289+
if (profile) {
290+
String profileName = "src/main/resources/application-${profile}.yaml"
291+
log.debug("Loading profile '${profileName}'")
292+
def file
293+
try {
294+
file = new File(profileName)
295+
296+
} catch (Exception e) {
297+
throw new RuntimeException("Profile '${profileName}' does not exist.")
298+
}
299+
Map profileFile = validateConfig(file.text)
300+
profileConfig = Config.fromMap(profileFile)
301+
}
302+
return profileConfig
303+
}
277304
}

src/main/groovy/com/cloudogu/gitops/config/Config.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ class Config {
407407
@JsonPropertyDescription(CLUSTER_ADMIN_DESCRIPTION)
408408
Boolean clusterAdmin = false
409409

410+
@Option(names = ["-p", "--profile"], description = APPLICATION_PROFIL)
411+
String profile
412+
410413
static class NamespaceSchema {
411414
LinkedHashSet<String> dedicatedNamespaces = new LinkedHashSet<>()
412415
LinkedHashSet<String> tenantNamespaces = new LinkedHashSet<>()

src/main/groovy/com/cloudogu/gitops/config/ConfigConstants.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ interface ConfigConstants {
9292
String NETPOLS_DESCRIPTION = 'Sets Network Policies'
9393
String CLUSTER_ADMIN_DESCRIPTION = 'Binds ArgoCD controllers to cluster-admin ClusterRole'
9494
String OPENSHIFT_DESCRIPTION = 'When set, openshift specific resources and configurations are applied'
95+
String APPLICATION_PROFIL = 'Use predefined profile (full, only-argocd, operator-mandants aso.)'
9596

9697
// group metrics
9798
String MONITORING_DESCRIPTION = 'Config parameters for the Monitoring system (prometheus)'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
2+
application:
3+
"yes": true
4+
baseUrl: http://localhost
5+
features:
6+
argocd:
7+
active: true
8+
operator: false
9+
ingressNginx:
10+
active: true
11+
content:
12+
examples: true
13+
jenkins:
14+
active: true
15+
registry:
16+
active: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
2+
application:
3+
"yes": true
4+
baseUrl: http://my-prefix.localhost
5+
namePrefix: my-prefix
6+
features:
7+
certManager:
8+
active: true
9+
argocd:
10+
active: true
11+
operator: false
12+
ingressNginx:
13+
active: true
14+
monitoring:
15+
active: true
16+
secrets:
17+
vault:
18+
mode: "dev"
19+
content:
20+
examples: true
21+
jenkins:
22+
active: true
23+
registry:
24+
active: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
2+
application:
3+
"yes": true
4+
baseUrl: http://localhost
5+
features:
6+
certManager:
7+
active: true
8+
argocd:
9+
active: true
10+
operator: false
11+
ingressNginx:
12+
active: true
13+
monitoring:
14+
active: true
15+
secrets:
16+
vault:
17+
mode: "dev"
18+
content:
19+
examples: true
20+
jenkins:
21+
active: true
22+
registry:
23+
active: true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
2+
application:
3+
"yes": true
4+
baseUrl: http://localhost
5+
insecure: true
6+
features:
7+
certManager:
8+
active: true
9+
argocd:
10+
active: true
11+
operator: true
12+
resourceInclusionsCluster: "https://10.43.0.1:443"
13+
ingressNginx:
14+
active: true
15+
monitoring:
16+
active: true
17+
secrets:
18+
vault:
19+
mode: "dev"
20+
content:
21+
examples: true
22+
jenkins:
23+
active: true
24+
registry:
25+
active: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
2+
content:
3+
multitenancyExamples: true
4+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# $schema: https://raw.githubusercontent.com/cloudogu/gitops-playground/main/docs/configuration.schema.json
2+
application:
3+
"yes": true
4+
baseUrl: http://localhost
5+
insecure: true
6+
features:
7+
argocd:
8+
active: true
9+
operator: true
10+
resourceInclusionsCluster: "https://10.43.0.1:443"
11+
content:
12+
examples: true
13+
jenkins:
14+
active: true
15+
registry:
16+
active: true

0 commit comments

Comments
 (0)