Skip to content

Commit 86d9334

Browse files
committed
Merge branch 'feature/helm_operator_1_1' of https://github.com/oracle/weblogic-kubernetes-operator into feature/helm_operator_1_1
Synchronize work
2 parents 2725e98 + 067ce51 commit 86d9334

File tree

7 files changed

+304
-57
lines changed

7 files changed

+304
-57
lines changed
Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,70 @@
11
# Copyright 2018 Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

4+
{{/*
5+
Record a validation error (it will get reported later by operator reportValidationErrors)
6+
*/}}
7+
{{- define "operator.recordValidationError" -}}
8+
{{- $scope := index . 0 -}}
9+
{{- $errorMsg := index . 1 -}}
10+
{{- if hasKey $scope "validationErrors" -}}
11+
{{- $newValidationErrors := cat $scope.validationErrors "\n" $errorMsg -}}
12+
{{- $ignore := set $scope "validationErrors" $newValidationErrors -}}
13+
{{- else -}}
14+
{{- $newValidationErrors := cat "\n" $errorMsg -}}
15+
{{- $ignore := set $scope "validationErrors" $newValidationErrors -}}
16+
{{- end -}}
17+
{{- end -}}
18+
419
{{/*
520
Verify that an input value of a specific kind has been specified.
621
*/}}
722
{{- define "operator.verifyInputKind" -}}
823
{{- $requiredKind := index . 0 -}}
924
{{- $scope := index . 1 -}}
10-
{{- $value := index . 1 -}}
1125
{{- $name := index . 2 -}}
12-
{{- if not ( hasKey $scope $name ) -}}
26+
{{- if hasKey $scope $name -}}
27+
{{- $value := index $scope $name -}}
28+
{{- $actualKind := kindOf $value -}}
29+
{{- if eq $requiredKind $actualKind -}}
30+
true
31+
{{- else -}}
32+
{{- $errorMsg := cat "The" $actualKind "property" $name "must be a" $requiredKind "instead." -}}
33+
{{- include "operator.recordValidationError" (list $scope $errorMsg) -}}
34+
{{- end -}}
35+
{{- else -}}
1336
{{- $errorMsg := cat "The" $requiredKind "property" $name "must be specified." -}}
14-
{{- $ignore := required $errorMsg "" -}}
15-
{{- end -}}
16-
{{- $value := index $scope $name -}}
17-
{{- $actualKind := kindOf $value -}}
18-
{{- if not ( eq $requiredKind $actualKind ) -}}
19-
{{- $errorMsg := cat "The" $actualKind "property" $name "must be a" $requiredKind "instead." -}}
20-
{{- $ignore := required $errorMsg "" -}}
37+
{{- include "operator.recordValidationError" (list $scope $errorMsg) -}}
2138
{{- end -}}
2239
{{- end -}}
2340

2441
{{/*
2542
Verify that a string input value has been specified
2643
*/}}
2744
{{- define "operator.verifyStringInput" -}}
28-
{{- include "operator.verifyInputKind" ( list "string" ( index . 0 ) ( index . 1 ) ) -}}
45+
{{- $args := . -}}
46+
{{- include "operator.verifyInputKind" (prepend $args "string") -}}
2947
{{- end -}}
3048

3149
{{/*
3250
Verify that a boolean input value has been specified
3351
*/}}
3452
{{- define "operator.verifyBooleanInput" -}}
35-
{{- include "operator.verifyInputKind" ( list "bool" ( index . 0 ) ( index . 1 ) ) -}}
53+
{{- include "operator.verifyInputKind" (prepend . "bool") -}}
3654
{{- end -}}
3755

3856
{{/*
3957
Verify that an integer input value has been specified
4058
*/}}
4159
{{- define "operator.verifyIntegerInput" -}}
42-
{{- include "operator.verifyInputKind" ( list "float64" ( index . 0 ) ( index . 1 ) ) -}}
60+
{{- include "operator.verifyInputKind" (prepend . "float64") -}}
4361
{{- end -}}
4462

4563
{{/*
4664
Verify that an object input value has been specified
4765
*/}}
4866
{{- define "operator.verifyObjectInput" -}}
49-
{{- include "operator.verifyInputKind" ( list "map" ( index . 0 ) ( index . 1 ) ) -}}
67+
{{- include "operator.verifyInputKind" (prepend . "map") -}}
5068
{{- end -}}
5169

5270
{{/*
@@ -56,10 +74,23 @@ Verify that an enum string input value has been specified
5674
{{- $scope := index . 0 -}}
5775
{{- $name := index . 1 -}}
5876
{{- $legalValues := index . 2 -}}
59-
{{- include "operator.verifyStringInput" ( list $scope $name ) -}}
60-
{{- $value := index $scope $name -}}
61-
{{- if not ( has $value $legalValues ) -}}
62-
{{ $errorMsg := cat "The property" $name "must be one of following values" $legalValues "instead of" $value -}}
63-
{{- $ignore := required $errorMsg "" -}}
77+
{{- if include "operator.verifyStringInput" (list $scope $name) -}}
78+
{{- $value := index $scope $name -}}
79+
{{- if has $value $legalValues -}}
80+
true
81+
{{- else -}}
82+
{{ $errorMsg := cat "The property" $name "must be one of following values" $legalValues "instead of" $value -}}
83+
{{- include "operator.recordValidationError" (list $scope $errorMsg) -}}
84+
{{- end -}}
6485
{{- end -}}
6586
{{- end -}}
87+
88+
{{/*
89+
Report the validation errors that have been found then kill the helm chart install
90+
*/}}
91+
{{- define "operator.reportValidationErrors" -}}
92+
{{- if .validationErrors -}}
93+
{{- $ignore := required .validationErrors "" -}}
94+
{{- end -}}
95+
{{- end -}}
96+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2018 Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
{{- define "operator.extraResources" }}
5+
{{- range $idx, $element := .extraResources }}
6+
---
7+
{{ toYaml $element }}
8+
{{- end }}
9+
{{- end }}

kubernetes/charts/weblogic-operator/templates/_validate-inputs.tpl

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,52 @@
33

44
{{- define "operator.validateInputs" -}}
55
{{- $scope := . -}}
6-
{{- include "operator.verifyBooleanInput" (list . "setupKubernetesCluster") -}}
7-
{{- include "operator.verifyBooleanInput" (list . "createOperator") -}}
8-
{{- if (or .setupKubernetesCluster .createOperator) }}
9-
{{- include "operator.verifyBooleanInput" (list . "elkIntegrationEnabled") -}}
6+
{{- if include "operator.verifyBooleanInput" (list $scope "setupKubernetesCluster") -}}
7+
{{- if $scope.setupKubernetesCluster }}
8+
{{- $ignore := include "operator.verifyBooleanInput" (list $scope "elkIntegrationEnabled") -}}
9+
{{- end }}
1010
{{- end }}
11-
{{- if .createOperator }}
12-
{{- include "operator.verifyBooleanInput" (list . "createOperatorNamespace") -}}
13-
{{- include "operator.verifyStringInput" (list . "operatorNamespace") -}}
14-
{{- include "operator.verifyStringInput" (list . "operatorServiceAccount") -}}
15-
{{- include "operator.verifyStringInput" (list . "operatorImage") -}}
16-
{{- include "operator.verifyEnumInput" (list . "operatorImagePullPolicy" (list "Always" "IfNotPresent" "Never")) -}}
17-
{{- include "operator.verifyStringInput" (list . "internalOperatorCert") -}}
18-
{{- include "operator.verifyStringInput" (list . "internalOperatorKey") -}}
19-
{{- include "operator.verifyBooleanInput" (list . "externalRestEnabled") -}}
20-
{{- include "operator.verifyBooleanInput" (list . "remoteDebugNodePortEnabled") -}}
21-
{{- include "operator.verifyEnumInput" (list . "javaLoggingLevel" (list "SEVERE" "WARNING" "INFO" "CONFIG" "FINE" "FINER" "FINEST")) -}}
22-
{{- include "operator.verifyObjectInput" (list . "domainsNamespaces") -}}
23-
{{- if .externalRestEnabled -}}
24-
{{- include "operator.verifyIntegerInput" (list . "externalRestHttpsPort") -}}
25-
{{- include "operator.verifyStringInput" (list . "externalOperatorCert") -}}
26-
{{- include "operator.verifyStringInput" (list . "externalOperatorKey") -}}
27-
{{- end -}}
28-
{{- if .remoteDebugNodePortEnabled -}}
29-
{{- include "operator.verifyIntegerInput" (list . "internalDebugHttpPort") -}}
30-
{{- include "operator.verifyIntegerInput" (list . "externalDebugHttpPort") -}}
31-
{{- end -}}
32-
{{- $domainsNamespaces := .domainsNamespaces -}}
33-
{{- range $key, $element := .domainsNamespaces -}}
34-
{{- include "operator.verifyObjectInput" (list $domainsNamespaces $key) -}}
35-
{{- $s := merge (dict) $element $scope -}}
36-
{{- include "operator.verifyBooleanInput" (list $s "createDomainsNamespace") -}}
11+
{{- if include "operator.verifyBooleanInput" (list $scope "createOperator") -}}
12+
{{- if .createOperator }}
13+
{{- $ignore := include "operator.verifyBooleanInput" (list $scope "elkIntegrationEnabled") -}}
14+
{{- $ignore := include "operator.verifyBooleanInput" (list $scope "createOperatorNamespace") -}}
15+
{{- $ignore := include "operator.verifyStringInput" (list $scope "operatorNamespace") -}}
16+
{{- $ignore := include "operator.verifyStringInput" (list $scope "operatorServiceAccount") -}}
17+
{{- $ignore := include "operator.verifyStringInput" (list $scope "operatorImage") -}}
18+
{{- $ignore := include "operator.verifyEnumInput" (list $scope "operatorImagePullPolicy" (list "Always" "IfNotPresent" "Never")) -}}
19+
{{- $ignore := include "operator.verifyEnumInput" (list $scope "javaLoggingLevel" (list "SEVERE" "WARNING" "INFO" "CONFIG" "FINE" "FINER" "FINEST")) -}}
20+
{{- $ignore := include "operator.verifyStringInput" (list $scope "internalOperatorCert") -}}
21+
{{- $ignore := include "operator.verifyStringInput" (list $scope "internalOperatorKey") -}}
22+
{{- if include "operator.verifyBooleanInput" (list $scope "externalRestEnabled") -}}
23+
{{- if $scope.externalRestEnabled -}}
24+
{{- $ignore := include "operator.verifyIntegerInput" (list $scope "externalRestHttpsPort") -}}
25+
{{- $ignore := include "operator.verifyStringInput" (list $scope "externalOperatorCert") -}}
26+
{{- $ignore := include "operator.verifyStringInput" (list $scope "externalOperatorKey") -}}
27+
{{- end -}}
28+
{{- end -}}
29+
{{- if include "operator.verifyBooleanInput" (list $scope "remoteDebugNodePortEnabled") -}}
30+
{{- if $scope.remoteDebugNodePortEnabled -}}
31+
{{- $ignore := include "operator.verifyIntegerInput" (list $scope "internalDebugHttpPort") -}}
32+
{{- $ignore := include "operator.verifyIntegerInput" (list $scope "externalDebugHttpPort") -}}
33+
{{- end -}}
34+
{{- end -}}
35+
{{- if include "operator.verifyObjectInput" (list $scope "domainsNamespaces") -}}
36+
{{- $domainsNamespaces := $scope.domainsNamespaces -}}
37+
{{- range $key, $element := $domainsNamespaces -}}
38+
{{- if include "operator.verifyObjectInput" (list $domainsNamespaces $key) -}}
39+
{{- $s := merge (dict) $element $scope -}}
40+
{{- if include "operator.verifyBooleanInput" (list $s "createDomainsNamespace") -}}
41+
{{- if eq $key "default" -}}
42+
{{- if $s.createDomainsNamespace -}}
43+
{{- $errorMsg := cat "The effective createDomainsNamespace value for the 'default' domainsNamespace must be set to false." -}}
44+
{{- $ignore := include "operator.recordValidationError" (list $scope $errorMsg) -}}
45+
{{- end -}}
46+
{{- end -}}
47+
{{- end -}}
48+
{{- end -}}
49+
{{- end -}}
50+
{{- end -}}
3751
{{- end -}}
3852
{{- end -}}
53+
{{- include "operator.reportValidationErrors" $scope -}}
3954
{{- end -}}

kubernetes/charts/weblogic-operator/templates/main.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
{{- if .Values.createOperator }}
1515
{{- include "operator.operator" $scope }}
1616
{{- end }}
17+
18+
{{- include "operator.extraResources" $scope }}
Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,112 @@
11
# Copyright 2018 Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

4+
# setupKubernetesCluster specifies whether or not the installation should deploy Kubernetes components
5+
# such as elasticsearch, kibana, operator RBAC roles, etc.
46
setupKubernetesCluster: true
7+
8+
# createOperator specifies whether or not the installation should create the operator and its resources.
59
createOperator: true
10+
11+
# createOperatorNamespace specifies whether or not the installation should create the Kubernetes
12+
# namespace that the operator will be deployed in. If createOperatorNamespace is false than the
13+
# namespace must exist before the operator can be installed.
614
createOperatorNamespace: true
7-
operatorNamespace: weblogic-operator
8-
operatorServiceAccount: weblogic-operator
15+
16+
# operatorNamespace specifies the name of the Kubernetes namespace that the operator will be deployed in.
17+
# It is recommended that a namespace be created for the operator rather
18+
# than using the default namespace.
19+
# The name must be lowercase
20+
operatorNamespace: "weblogic-operator"
21+
22+
# operatorServiceAccount specifies the name of the service account that the operator will use to
23+
# make requests to the Kubernetes API server.
24+
# The name must be lowercase
25+
operatorServiceAccount: "weblogic-operator"
26+
27+
# createDomainsNamespace is a global variable that specifies whether or not the helm installation should create the Kubernetes
28+
# namespaces for the domains specified in domainsNamespaces.
929
createDomainsNamespace: true
30+
31+
# domainsNamespaces specifies a map of WebLogic Domain namespaces which the operator manages (same as targetNamespaces but in map format)
32+
# The names must be lowercase
33+
#
34+
# Example 1: In the configuration below, the helm installation will create the Domain namespace 'namespace2' but not 'namespace1'.
35+
#
36+
# createDomainsNamespace: true
37+
# domainsNamespaces:
38+
# namespace1:
39+
# createDomainsNamespace: false
40+
# namespace2: {}
41+
#
42+
#-----------------------------------
43+
#
44+
# Example 2: In the configuration below, the helm installation will create the Domain namespace 'namespace2' but not 'namespace1'.
45+
#
46+
# createDomainsNamespace: false
47+
# domainsNamespaces:
48+
# namespace1: {}
49+
# namespace2:
50+
# createDomainsNamespace: true
51+
#
1052
domainsNamespaces: {}
11-
operatorImage: weblogic-kubernetes-operator:1.0
12-
operatorImagePullPolicy: IfNotPresent
13-
#internalOperatorCert: ...
14-
#internalOperatorKey: ...
53+
54+
# operatorImage specifies the docker image containing the operator code.
55+
operatorImage: "weblogic-kubernetes-operator:1.0"
56+
57+
# operatorImagePullPolicy specifies the image pull policy for the operator docker image.
58+
operatorImagePullPolicy: "IfNotPresent"
59+
60+
# externalRestEnabled specifies whether or not the operator externally exposes a REST https interface
61+
# (i.e. outside of the Kubernetes cluster).
1562
externalRestEnabled: false
63+
64+
# externalRestHttpsPort specifies the node port that should be allocated for the external operator REST https interface.
65+
# This parameter is required if 'externalRestEnabled' is 'true'.
66+
# Otherwise, it is ignored.
1667
externalRestHttpsPort: 31001
17-
#externalOperatorCert: ...
18-
#externalOperatorKey: ...
68+
69+
# remoteDebugNodePortEnabled specifies whether or not the operator will start a Java remote debug server on the
70+
# provided port and suspend execution until a remote debugger has attached.
71+
# The 'internalDebugHttpPort' property controls the port number inside the Kubernetes
72+
# cluster and the 'externalDebugHttpPort' property controls the port number outside
73+
# the Kubernetes cluster.
1974
remoteDebugNodePortEnabled: false
75+
76+
# internalDebugHttpPort specifes the port number inside the Kubernetes cluster for the operator's Java
77+
# remote debug server.
78+
# This parameter is required if 'remoteDebugNodePortEnabled' is true.
79+
# Otherwise, it is ignored.
2080
internalDebugHttpPort: 30999
81+
82+
# externalDebugHttpPort specifies the node port that should be allocated for the Kubernetes cluster for the operator's
83+
# Java remote debug server.
84+
# This parameter is required if 'remoteDebugNodePortEnabled' is true.
85+
# Otherwise, it is ignored.
2186
externalDebugHttpPort: 30999
22-
javaLoggingLevel: INFO
87+
88+
# javaLoggingLevel specifies the level of Java logging that should be enabled in the operator.
89+
# Valid values are: "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", and "FINEST".
90+
javaLoggingLevel: "INFO"
91+
92+
# elkIntegrationEnabled specifies whether or not ELK integration is enabled.
2393
elkIntegrationEnabled: false
94+
95+
# extraResources specifies an arbitrary list of extra Kubernetes resources that should be
96+
# created (and deleted) along with this chart. It provides an easy way for the
97+
# customer to attach extra Kubernetes resources to the lifecycle of this chart.
98+
#
99+
# Example: create an extra persistent volume and persistent claim when this chart is
100+
# installed, and remove them when this chart is deleted:
101+
#
102+
# extraResources:
103+
# - kind: PersistentVolume
104+
# apiVersion: v1
105+
# metadata: ...
106+
# spec: ...
107+
# - kind: PersistentVolumeClaim
108+
# apiVersion: v1
109+
# metadata: ...
110+
# spec: ...
111+
#
112+
extraResources: {}

kubernetes/internal/set-operator-certificate.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ trap "cleanup" EXIT
3535
cert_data=`base64 -i ${cert_file} | tr -d '\n'`
3636
key_data=`base64 -i ${key_file} | tr -d '\n'`
3737

38+
echo "# ${prefix}OperatorCert specifies the certificate to use for the ${prefix} operator REST"
39+
echo "# Value is generated by the generate-${prefix}-weblogic-operator-certificate script."
3840
echo "${prefix}OperatorCert: ${cert_data}"
41+
echo ""
42+
43+
echo "# ${prefix}OperatorKey specifies the private key to use for the ${prefix} operator REST"
44+
echo "# Value is generated by the generate-${prefix}-weblogic-operator-certificate script."
3945
echo "${prefix}OperatorKey: ${key_data}"
46+
echo ""
4047

4148
succeeded=true

0 commit comments

Comments
 (0)