Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit caf9034

Browse files
improvements and fixes for an idempotent result (#166)
1 parent b4f41e0 commit caf9034

File tree

4 files changed

+79
-11
lines changed

4 files changed

+79
-11
lines changed

.generate/gen-all.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# Before run this script ensure that you have helm installed locally
18+
# with the stable repo as well. The helm sample will use the memcached chart
19+
# from helm repository.
20+
# To install: https://helm.sh/docs/intro/install/
21+
# To add the repo run `helm repo add stable https://charts.helm.sh/stable`
22+
1723
set -o errexit
1824
set -o pipefail
1925

helm/.generate/gen-helm-memcached.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# Before run this script ensure that you have helm installed locally
18+
# with the stable repo as well. The helm sample will use the memcached chart
19+
# from helm repository.
20+
# To install: https://helm.sh/docs/intro/install/
21+
# To add the repo run `helm repo add stable https://charts.helm.sh/stable`
22+
1723
set -o errexit
1824
set -o pipefail
1925

@@ -36,6 +42,18 @@ function header_text {
3642
}
3743

3844
function gen_helm_sample {
45+
46+
# When operator-sdk scaffolds Helm projects, it tries to use the discovery API of a Kubernetes
47+
# cluster to intelligently build the RBAC rules that the operator will require based on the
48+
# content of the helm chart.
49+
#
50+
# Here, we intentionally set KUBECONFIG to a broken value to ensure that operator-sdk will be
51+
# unable to reach a real cluster, and thus will generate a default RBAC rule set. This is
52+
# required to make Helm project generation idempotent because contributors and CI environments
53+
# can all have slightly different environments that can affect the content of the generated
54+
# role and cause sanity testing to fail.
55+
export KUBECONFIG="broken_so_we_generate_static_default_rules"
56+
3957
local operIMG="quay.io/example-inc/memcached-operator:v0.0.1"
4058
local bundleIMG="quay.io/example-inc/memcached-operator-bundle:v0.0.1"
4159

helm/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,37 @@ spec:
110110
- apiGroups:
111111
- ""
112112
resources:
113+
- pods
113114
- services
115+
- services/finalizers
116+
- endpoints
117+
- persistentvolumeclaims
118+
- events
119+
- configmaps
120+
- secrets
114121
verbs:
115-
- '*'
122+
- create
123+
- delete
124+
- get
125+
- list
126+
- patch
127+
- update
128+
- watch
116129
- apiGroups:
117130
- apps
118131
resources:
132+
- deployments
133+
- daemonsets
134+
- replicasets
119135
- statefulsets
120136
verbs:
121-
- '*'
137+
- create
138+
- delete
139+
- get
140+
- list
141+
- patch
142+
- update
143+
- watch
122144
- apiGroups:
123145
- policy
124146
resources:

helm/memcached-operator/config/rbac/role.yaml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,40 @@ rules:
4444
- patch
4545
- update
4646
- watch
47-
- verbs:
48-
- "*"
49-
apiGroups:
47+
- apiGroups:
5048
- ""
5149
resources:
52-
- "services"
53-
- verbs:
54-
- "*"
55-
apiGroups:
56-
- "apps"
50+
- pods
51+
- services
52+
- services/finalizers
53+
- endpoints
54+
- persistentvolumeclaims
55+
- events
56+
- configmaps
57+
- secrets
58+
verbs:
59+
- create
60+
- delete
61+
- get
62+
- list
63+
- patch
64+
- update
65+
- watch
66+
- apiGroups:
67+
- apps
5768
resources:
58-
- "statefulsets"
69+
- deployments
70+
- daemonsets
71+
- replicasets
72+
- statefulsets
73+
verbs:
74+
- create
75+
- delete
76+
- get
77+
- list
78+
- patch
79+
- update
80+
- watch
5981

6082
##
6183
## Rules customized for cache.example.com/v1alpha1, Kind: Memcached

0 commit comments

Comments
 (0)