Skip to content

Commit ea7eafe

Browse files
author
Eric Stroczynski
authored
deps: bump kubebuilder to dd3942c (#4626)
Signed-off-by: Eric Stroczynski <[email protected]>
1 parent 4934838 commit ea7eafe

File tree

23 files changed

+190
-61
lines changed

23 files changed

+190
-61
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
entries:
2+
- description: >
3+
(go/v3) Pin controller-runtime to v0.7.2
4+
kind: change
5+
migration:
6+
header: (go/v3) Upgrade controller-runtime to v0.7.2
7+
body: >
8+
In your go.mod file, upgrade `sigs.k8s.io/controller-runtime` to v0.7.2.
9+
- description: >
10+
(go/v3) Create and bind to a non-default service account ([kubebuilder#2070](https://github.com/kubernetes-sigs/kubebuilder/pull/2070))
11+
kind: addition
12+
migration:
13+
header: (go/v3) Add a `system:controller-manager` ServiceAccount to your project.
14+
body: >
15+
A non-default ServiceAccount `controller-manager` is scaffolded on `operator-sdk init`,
16+
to improve security for operators installed in shared namespaces. To add this ServiceAccount
17+
to your project, do the following:
18+
19+
```sh
20+
# Create the ServiceAccount.
21+
cat <<EOF > config/rbac/service_account.yaml
22+
apiVersion: v1
23+
kind: ServiceAccount
24+
metadata:
25+
name: controller-manager
26+
namespace: system
27+
EOF
28+
29+
# Add it to the list of RBAC resources.
30+
echo "- service_account.yaml" >> config/rbac/kustomization.yaml
31+
32+
# Update all RoleBinding and ClusterRoleBinding subjects that reference the operator's ServiceAccount.
33+
find config/rbac -name *_binding.yaml -exec sed -i -E 's/ name: default/ name: controller-manager/g' {} \;
34+
35+
# Add the ServiceAccount name to the manager Deployment's spec.template.spec.serviceAccountName.
36+
sed -i -E 's/([ ]+)(terminationGracePeriodSeconds:)/\1serviceAccountName: controller-manager\n\1\2/g' config/manager/manager.yaml
37+
```
38+
39+
The changes should look like:
40+
41+
```diff
42+
# config/manager/manager.yaml
43+
requests:
44+
cpu: 100m
45+
memory: 20Mi
46+
+ serviceAccountName: controller-manager
47+
terminationGracePeriodSeconds: 10
48+
49+
# config/rbac/auth_proxy_role_binding.yaml
50+
name: proxy-role
51+
subjects:
52+
- kind: ServiceAccount
53+
- name: default
54+
+ name: controller-manager
55+
namespace: system
56+
57+
# config/rbac/kustomization.yaml
58+
resources:
59+
+- service_account.yaml
60+
- role.yaml
61+
- role_binding.yaml
62+
- leader_election_role.yaml
63+
64+
# config/rbac/leader_election_role_binding.yaml
65+
name: leader-election-role
66+
subjects:
67+
- kind: ServiceAccount
68+
- name: default
69+
+ name: controller-manager
70+
namespace: system
71+
72+
# config/rbac/role_binding.yaml
73+
name: manager-role
74+
subjects:
75+
- kind: ServiceAccount
76+
- name: default
77+
+ name: controller-manager
78+
namespace: system
79+
80+
# config/rbac/service_account.yaml
81+
+apiVersion: v1
82+
+kind: ServiceAccount
83+
+metadata:
84+
+ name: controller-manager
85+
+ namespace: system
86+
```

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ require (
99
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
1010
github.com/kr/text v0.1.0
1111
github.com/markbates/inflect v1.0.4
12-
github.com/onsi/ginkgo v1.14.1
13-
github.com/onsi/gomega v1.10.2
12+
github.com/onsi/ginkgo v1.15.0
13+
github.com/onsi/gomega v1.10.5
1414
github.com/operator-framework/api v0.5.3
1515
github.com/operator-framework/operator-lib v0.4.0
1616
github.com/operator-framework/operator-registry v1.15.3
@@ -22,7 +22,7 @@ require (
2222
github.com/spf13/pflag v1.0.5
2323
github.com/spf13/viper v1.7.0
2424
github.com/stretchr/testify v1.6.1
25-
golang.org/x/tools v0.0.0-20201014231627-1610a49f37af
25+
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e
2626
gomodules.xyz/jsonpatch/v3 v3.0.1
2727
helm.sh/helm/v3 v3.4.1
2828
k8s.io/api v0.20.2
@@ -34,7 +34,7 @@ require (
3434
rsc.io/letsencrypt v0.0.3 // indirect
3535
sigs.k8s.io/controller-runtime v0.8.2
3636
sigs.k8s.io/controller-tools v0.5.0
37-
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210211121616-05abe25e7215
37+
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210309225704-dd3942c97cf5
3838
sigs.k8s.io/yaml v1.2.0
3939
)
4040

go.sum

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,8 @@ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0
723723
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
724724
github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4=
725725
github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
726+
github.com/onsi/ginkgo v1.15.0 h1:1V1NfVQR87RtWAgp1lv9JZJ5Jap+XFGKPi00andXGi4=
727+
github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
726728
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
727729
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
728730
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@@ -733,6 +735,8 @@ github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT
733735
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
734736
github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs=
735737
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
738+
github.com/onsi/gomega v1.10.5 h1:7n6FEkpFmfCoo2t+YYqXH0evK+a9ICQz0xcAy9dYcaQ=
739+
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
736740
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
737741
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
738742
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
@@ -1085,10 +1089,11 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL
10851089
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
10861090
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
10871091
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
1088-
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
1089-
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
1092+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
10901093
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
10911094
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
1095+
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
1096+
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
10921097
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
10931098
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
10941099
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1104,8 +1109,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
11041109
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
11051110
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
11061111
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1107-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
1108-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1112+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
1113+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
11091114
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
11101115
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
11111116
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1167,6 +1172,8 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w
11671172
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11681173
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd h1:5CtCZbICpIOFdgO940moixOPjc0178IU44m4EjOO5IY=
11691174
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1175+
golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw=
1176+
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11701177
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
11711178
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
11721179
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1224,12 +1231,11 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK
12241231
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
12251232
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
12261233
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
1227-
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
12281234
golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
12291235
golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
12301236
golang.org/x/tools v0.0.0-20200616195046-dc31b401abb5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
1231-
golang.org/x/tools v0.0.0-20201014231627-1610a49f37af h1:VIUWFyOgzG3c0t9KYop5Ybp4m56LupfOnFYX7Ipnz+I=
1232-
golang.org/x/tools v0.0.0-20201014231627-1610a49f37af/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
1237+
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE=
1238+
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
12331239
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
12341240
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
12351241
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1481,8 +1487,8 @@ sigs.k8s.io/controller-tools v0.4.1 h1:VkuV0MxlRPmRu5iTgBZU4UxUX2LiR99n3sdQGRxZF
14811487
sigs.k8s.io/controller-tools v0.4.1/go.mod h1:G9rHdZMVlBDocIxGkK3jHLWqcTMNvveypYJwrvYKjWU=
14821488
sigs.k8s.io/controller-tools v0.5.0 h1:3u2RCwOlp0cjCALAigpOcbAf50pE+kHSdueUosrC/AE=
14831489
sigs.k8s.io/controller-tools v0.5.0/go.mod h1:JTsstrMpxs+9BUj6eGuAaEb6SDSPTeVtUyp0jmnAM/I=
1484-
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210211121616-05abe25e7215 h1:pwEHSu3/ODNEr33DNrKt2DovGV84LhRBLt4QyrT6FJA=
1485-
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210211121616-05abe25e7215/go.mod h1:b1WkCy5t/3VSRBCffSfPV1WbH+f45ls69d4ic37sW6w=
1490+
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210309225704-dd3942c97cf5 h1:tPK6p11aAjyXe79qsgJF2fvRnzEaYIYuzosFkK9OXDY=
1491+
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210309225704-dd3942c97cf5/go.mod h1:O+YpPPkBBBQ+H7b2W1SqL8ygxDHFrVanJICzV8ToZtE=
14861492
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
14871493
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
14881494
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=

internal/plugins/ansible/v1/api.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"sigs.k8s.io/kubebuilder/v3/pkg/config"
2424
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
2525
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
26+
pluginutil "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
2627
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
2728

2829
"github.com/operator-framework/operator-sdk/internal/kubebuilder/cmdutil"
@@ -167,8 +168,8 @@ func (p *createAPIPSubcommand) Validate() error {
167168
return errors.New("multiple groups are not allowed by default, to enable multi-group set 'multigroup: true' in your PROJECT file")
168169
}
169170

170-
// Check CRDVersion against all other CRDVersions in p.config for compatibility.
171-
if !p.config.IsCRDVersionCompatible(p.resource.API.CRDVersion) {
171+
// Selected CRD version must match existing CRD versions.
172+
if pluginutil.HasDifferentCRDVersion(p.config, p.resource.API.CRDVersion) {
172173
return fmt.Errorf("only one CRD version can be used for all resources, cannot add %q", p.resource.API.CRDVersion)
173174
}
174175

internal/plugins/helm/v1/api.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"sigs.k8s.io/kubebuilder/v3/pkg/config"
2525
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
2626
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
27+
pluginutil "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
2728

2829
"github.com/operator-framework/operator-sdk/internal/kubebuilder/cmdutil"
2930
"github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/chartutil"
@@ -196,8 +197,8 @@ func (p *createAPISubcommand) Validate() (err error) {
196197
return errors.New("multiple groups are not allowed by default, to enable multi-group set 'multigroup: true' in your PROJECT file")
197198
}
198199

199-
// Check CRDVersion against all other CRDVersions in p.config for compatibility.
200-
if !p.config.IsCRDVersionCompatible(p.resource.API.CRDVersion) {
200+
// Selected CRD version must match existing CRD versions.
201+
if pluginutil.HasDifferentCRDVersion(p.config, p.resource.API.CRDVersion) {
201202
return fmt.Errorf("only one CRD version can be used for all resources, cannot add %q", p.resource.API.CRDVersion)
202203
}
203204

test/e2e/go/cluster_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,17 @@ var _ = Describe("operator-sdk", func() {
119119
}, time.Minute, time.Second).Should(Succeed())
120120

121121
By("granting permissions to access the metrics and read the token")
122-
_, err = tc.Kubectl.Command(
123-
"create",
124-
"clusterrolebinding", metricsClusterRoleBindingName,
122+
_, err = tc.Kubectl.Command("create", "clusterrolebinding", metricsClusterRoleBindingName,
125123
fmt.Sprintf("--clusterrole=%s-metrics-reader", tc.ProjectName),
126-
fmt.Sprintf("--serviceaccount=%s:default", tc.Kubectl.Namespace))
124+
fmt.Sprintf("--serviceaccount=%s:%s", tc.Kubectl.Namespace, tc.Kubectl.ServiceAccount))
127125
Expect(err).NotTo(HaveOccurred())
128126

129-
By("reading the token")
130-
b64Token, err := tc.Kubectl.Get(
131-
true,
132-
"secrets",
133-
"-o=jsonpath={.items[0].data.token}")
127+
By("reading the metrics token")
128+
// Filter token query by service account in case more than one exists in a namespace.
129+
query := fmt.Sprintf(`{.items[?(@.metadata.annotations.kubernetes\.io/service-account\.name=="%s")].data.token}`,
130+
tc.Kubectl.ServiceAccount,
131+
)
132+
b64Token, err := tc.Kubectl.Get(true, "secrets", "-o=jsonpath="+query)
134133
Expect(err).NotTo(HaveOccurred())
135134
token, err := base64.StdEncoding.DecodeString(strings.TrimSpace(b64Token))
136135
Expect(err).NotTo(HaveOccurred())
@@ -141,7 +140,8 @@ var _ = Describe("operator-sdk", func() {
141140
// it should not make any difference and work locally successfully when the flag is removed
142141
// the test will fail and the curl pod is not found when the flag is not used
143142
cmdOpts := []string{
144-
"run", "--generator=run-pod/v1", "curl", "--image=curlimages/curl:7.68.0", "--restart=OnFailure", "--",
143+
"run", "--generator=run-pod/v1", "curl", "--image=curlimages/curl:7.68.0", "--restart=OnFailure",
144+
"--serviceaccount", tc.Kubectl.ServiceAccount, "--",
145145
"curl", "-v", "-k", "-H", fmt.Sprintf(`Authorization: Bearer %s`, token),
146146
fmt.Sprintf("https://%s-controller-manager-metrics-service.%s.svc:8443/metrics", tc.ProjectName, tc.Kubectl.Namespace),
147147
}

test/e2e/go/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var _ = BeforeSuite(func() {
5353
tc.Resources = "memcacheds"
5454
tc.ProjectName = "memcached-operator"
5555
tc.Kubectl.Namespace = fmt.Sprintf("%s-system", tc.ProjectName)
56+
tc.Kubectl.ServiceAccount = fmt.Sprintf("%s-controller-manager", tc.ProjectName)
5657

5758
By("copying sample to a temporary e2e directory")
5859
Expect(exec.Command("cp", "-r", "../../../testdata/go/v3/memcached-operator", tc.Dir).Run()).To(Succeed())

testdata/go/v2/memcached-operator/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ go 1.13
44

55
require (
66
github.com/go-logr/logr v0.1.0
7+
github.com/onsi/ginkgo v1.12.1
8+
github.com/onsi/gomega v1.10.1
79
k8s.io/api v0.18.6
810
k8s.io/apimachinery v0.18.6
911
k8s.io/client-go v0.18.6

testdata/go/v3/memcached-operator/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ vet: ## Run go vet against code.
7575
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
7676
test: manifests generate fmt vet ## Run tests.
7777
mkdir -p ${ENVTEST_ASSETS_DIR}
78-
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.0/hack/setup-envtest.sh
78+
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
7979
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
8080

8181
##@ Build
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
creationTimestamp: null
5+
name: memcached-operator-controller-manager

0 commit comments

Comments
 (0)