-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible/helm - apply the service acount
Signed-off-by: Camila Macedo <cmacedo@redhat.com>
- Loading branch information
Camila Macedo
committed
Mar 16, 2021
1 parent
f28e25b
commit 8fb8252
Showing
28 changed files
with
529 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,86 @@ | ||
# entries is a list of entries to include in | ||
# release notes and/or the migration guide | ||
entries: | ||
- description: > | ||
(ansible/v1) (helm/v1) Create and bind to a non-default service account ([kubebuilder#2070](https://github.com/kubernetes-sigs/kubebuilder/pull/2070)) | ||
kind: addition | ||
- description: > | ||
(ansible/v1, helm/v1) Create and bind to a non-default service account ([kubebuilder#2070](https://github.com/kubernetes-sigs/kubebuilder/pull/2070)) | ||
kind: "addition" | ||
breaking: false | ||
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS | ||
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST! | ||
# | ||
# The generator auto-detects the PR number from the commit | ||
# message in which this file was originally added. | ||
# | ||
# What is the pull request number (without the "#")? | ||
# pull_request_override: 0 | ||
# Migration can be defined to automatically add a section to | ||
# the migration guide. This is required for breaking changes. | ||
migration: | ||
header: (go/v3) Add a `system:controller-manager` ServiceAccount to your project. | ||
body: > | ||
A non-default ServiceAccount `controller-manager` is scaffolded on `operator-sdk init`, | ||
to improve security for operators installed in shared namespaces. To add this ServiceAccount | ||
to your project, do the following: | ||
```sh | ||
# Create the ServiceAccount. | ||
cat <<EOF > config/rbac/service_account.yaml | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
EOF | ||
# Add it to the list of RBAC resources. | ||
echo "- service_account.yaml" >> config/rbac/kustomization.yaml | ||
# Update all RoleBinding and ClusterRoleBinding subjects that reference the operator's ServiceAccount. | ||
find config/rbac -name *_binding.yaml -exec sed -i -E 's/ name: default/ name: controller-manager/g' {} \; | ||
# Add the ServiceAccount name to the manager Deployment's spec.template.spec.serviceAccountName. | ||
sed -i -E 's/([ ]+)(terminationGracePeriodSeconds:)/\1serviceAccountName: controller-manager\n\1\2/g' config/manager/manager.yaml | ||
``` | ||
The changes should look like: | ||
```diff | ||
# config/manager/manager.yaml | ||
requests: | ||
cpu: 100m | ||
memory: 20Mi | ||
+ serviceAccountName: controller-manager | ||
terminationGracePeriodSeconds: 10 | ||
# config/rbac/auth_proxy_role_binding.yaml | ||
name: proxy-role | ||
subjects: | ||
- kind: ServiceAccount | ||
- name: default | ||
+ name: controller-manager | ||
namespace: system | ||
# config/rbac/kustomization.yaml | ||
resources: | ||
+- service_account.yaml | ||
- role.yaml | ||
- role_binding.yaml | ||
- leader_election_role.yaml | ||
# config/rbac/leader_election_role_binding.yaml | ||
name: leader-election-role | ||
subjects: | ||
- kind: ServiceAccount | ||
- name: default | ||
+ name: controller-manager | ||
namespace: system | ||
# config/rbac/role_binding.yaml | ||
name: manager-role | ||
subjects: | ||
- kind: ServiceAccount | ||
- name: default | ||
+ name: controller-manager | ||
namespace: system | ||
# config/rbac/service_account.yaml | ||
+apiVersion: v1 | ||
+kind: ServiceAccount | ||
+metadata: | ||
+ name: controller-manager | ||
+ namespace: system | ||
``` | ||
header: (ansible/v1, helm/v1) Add a `system:controller-manager` ServiceAccount to your project. | ||
body: > | ||
A non-default ServiceAccount `controller-manager` is scaffolded on `operator-sdk init`, | ||
to improve security for operators installed in shared namespaces. To add this ServiceAccount | ||
to your project, do the following: | ||
```sh | ||
# Create the ServiceAccount. | ||
cat <<EOF > config/rbac/service_account.yaml | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
EOF | ||
# Add it to the list of RBAC resources. | ||
echo "- service_account.yaml" >> config/rbac/kustomization.yaml | ||
# Update all RoleBinding and ClusterRoleBinding subjects that reference the operator's ServiceAccount. | ||
find config/rbac -name *_binding.yaml -exec sed -i -E 's/ name: default/ name: controller-manager/g' {} \; | ||
# Add the ServiceAccount name to the manager Deployment's spec.template.spec.serviceAccountName. | ||
sed -i -E 's/([ ]+)(terminationGracePeriodSeconds:)/\1serviceAccountName: controller-manager\n\1\2/g' config/manager/manager.yaml | ||
``` | ||
The changes should look like: | ||
```diff | ||
# config/manager/manager.yaml | ||
requests: | ||
cpu: 100m | ||
memory: 20Mi | ||
+ serviceAccountName: controller-manager | ||
terminationGracePeriodSeconds: 10 | ||
# config/rbac/auth_proxy_role_binding.yaml | ||
name: proxy-role | ||
subjects: | ||
- kind: ServiceAccount | ||
- name: default | ||
+ name: controller-manager | ||
namespace: system | ||
# config/rbac/kustomization.yaml | ||
resources: | ||
+- service_account.yaml | ||
- role.yaml | ||
- role_binding.yaml | ||
- leader_election_role.yaml | ||
# config/rbac/leader_election_role_binding.yaml | ||
name: leader-election-role | ||
subjects: | ||
- kind: ServiceAccount | ||
- name: default | ||
+ name: controller-manager | ||
namespace: system | ||
# config/rbac/role_binding.yaml | ||
name: manager-role | ||
subjects: | ||
- kind: ServiceAccount | ||
- name: default | ||
+ name: controller-manager | ||
namespace: system | ||
# config/rbac/service_account.yaml | ||
+apiVersion: v1 | ||
+kind: ServiceAccount | ||
+metadata: | ||
+ name: controller-manager | ||
+ namespace: system | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/service_account.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/service_account.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
testdata/ansible/memcached-operator/bundle/manifests/cache.example.com_memcacheds.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
creationTimestamp: null | ||
name: memcacheds.cache.example.com | ||
spec: | ||
group: cache.example.com | ||
names: | ||
kind: Memcached | ||
listKind: MemcachedList | ||
plural: memcacheds | ||
singular: memcached | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: Memcached is the Schema for the memcacheds API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: Spec defines the desired state of Memcached | ||
type: object | ||
x-kubernetes-preserve-unknown-fields: true | ||
status: | ||
description: Status defines the observed state of Memcached | ||
type: object | ||
x-kubernetes-preserve-unknown-fields: true | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: null | ||
storedVersions: null |
13 changes: 13 additions & 0 deletions
13
...-operator-controller-manager-metrics-monitor_monitoring.coreos.com_v1_servicemonitor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
labels: | ||
control-plane: controller-manager | ||
name: memcached-operator-controller-manager-metrics-monitor | ||
spec: | ||
endpoints: | ||
- path: /metrics | ||
port: https | ||
selector: | ||
matchLabels: | ||
control-plane: controller-manager |
16 changes: 16 additions & 0 deletions
16
...or/bundle/manifests/memcached-operator-controller-manager-metrics-service_v1_service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
control-plane: controller-manager | ||
name: memcached-operator-controller-manager-metrics-service | ||
spec: | ||
ports: | ||
- name: https | ||
port: 8443 | ||
targetPort: https | ||
selector: | ||
control-plane: controller-manager | ||
status: | ||
loadBalancer: {} |
5 changes: 5 additions & 0 deletions
5
...ed-operator/bundle/manifests/memcached-operator-controller-manager_v1_serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
creationTimestamp: null | ||
name: memcached-operator-controller-manager |
Oops, something went wrong.