Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit f1a359f

Browse files
author
Mathieu Benoit
committed
Config Sync's RepoSync with edit clusterrole for Istio resources (instead of clusteradmin)
1 parent 6ad2bf7 commit f1a359f

File tree

4 files changed

+52
-24
lines changed

4 files changed

+52
-24
lines changed

content/config-controller/set-up-config-controller-git-repo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ spec:
106106
name: git-creds
107107
EOF
108108
```
109-
{{% notice tips %}}
109+
{{% notice tip %}}
110110
The GitHub repository is private in order to demonstrate how to allow read access to Config Sync when you use a restricted Git repository.
111111
{{% /notice %}}
112112

content/onlineboutique/set-up-onlineboutique-git-repo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ subjects:
7979
namespace: config-management-system
8080
roleRef:
8181
kind: ClusterRole
82-
name: cluster-admin
82+
name: edit
8383
apiGroup: rbac.authorization.k8s.io
8484
EOF
8585
```
86-
{{% notice info %}}
87-
We are using the `cluster-admin` role here, but in the future we will change this with a least privilege approach. It will be something with `edit` role and the the Istio resources like `VirtualService`, etc. leveraged in this workshop. See [more information about the user-facing roles here](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles).
86+
{{% notice tip %}}
87+
We are using the [`edit` user-facing role](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles) here, to follow the least privilege principle. Earlier in this workshop during the ASM installation, we extended the default `edit` role with more capabilities regarding to the Istio resources: `VirtualService`, `Sidecar` and `Authorization` wich will be leveraged in the OnlineBoutique's namespace.
8888
{{% /notice %}}
8989

9090
## Deploy Kubernetes manifests

content/service-mesh/set-up-asm-configs.md

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,33 @@ spec: {}
9696
EOF
9797
```
9898

99+
## Define new ClusterRole with Istio capabilities for ConfigSync
100+
101+
Define the extended [`edit` user-facing role](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles) with more Istio resources capabilities:
102+
```Bash
103+
cat <<EOF > ~/$GKE_CONFIGS_DIR_NAME/config-sync/custom-edit-clusterrole-istio.yaml
104+
apiVersion: rbac.authorization.k8s.io/v1
105+
kind: ClusterRole
106+
metadata:
107+
labels:
108+
rbac.authorization.k8s.io/aggregate-to-edit: "true"
109+
name: custom:aggregate-to-edit:istio
110+
rules:
111+
- apiGroups:
112+
- "networking.istio.io"
113+
- "security.istio.io"
114+
resources:
115+
- "virtualservices"
116+
- "authorizationpolicies"
117+
- "sidecars"
118+
verbs:
119+
- "*"
120+
EOF
121+
```
122+
{{% notice tip %}}
123+
Later in this workshop, for each app namespace, we will define a Config Sync's `RepoSync` which will be bound to the `edit` `ClusterRole`. With that new extension, it will allow each namespace to deploy Istio resources such as `Sidecar`, `VirtualService` and `AuthorizationPolicy` while meeting with the least privilege principle requirement.
124+
{{% /notice %}}
125+
99126
## Deploy Kubernetes manifests
100127

101128
```Bash
@@ -131,21 +158,22 @@ gcloud alpha anthos config sync repo describe \
131158
```
132159
```Plaintext
133160
getting 1 RepoSync and RootSync from gke-hub-membership
134-
┌───────────────────────────┬──────────────────────┬──────────────────────────────┬──────────────────────────────┐
135-
│ GROUP │ KIND │ NAME │ NAMESPACE │
136-
├───────────────────────────┼──────────────────────┼──────────────────────────────┼──────────────────────────────┤
137-
│ │ Namespace │ istio-system │ │
138-
│ │ Namespace │ config-management-monitoring │ │
139-
│ constraints.gatekeeper.sh │ K8sRequiredLabels │ deployment-required-labels │ │
140-
│ constraints.gatekeeper.sh │ K8sRequiredLabels │ namespace-required-labels │ │
141-
│ constraints.gatekeeper.sh │ K8sAllowedRepos │ allowed-container-registries │ │
142-
│ networking.gke.io │ NetworkLogging │ default │ │
143-
│ templates.gatekeeper.sh │ ConstraintTemplate │ k8sallowedrepos │ │
144-
│ templates.gatekeeper.sh │ ConstraintTemplate │ k8srequiredlabels │ │
145-
│ │ ServiceAccount │ default │ config-management-monitoring │
146-
│ security.istio.io │ AuthorizationPolicy │ deny-all │ istio-system │
147-
│ │ ConfigMap │ istio-asm-managed-rapid │ istio-system │
148-
│ mesh.cloud.google.com │ ControlPlaneRevision │ asm-managed-rapid │ istio-system │
149-
│ security.istio.io │ PeerAuthentication │ default │ istio-system │
150-
└───────────────────────────┴──────────────────────┴──────────────────────────────┴──────────────────────────────┘
161+
┌───────────────────────────┬──────────────────────┬────────────────────────────────┬──────────────────────────────┐
162+
│ GROUP │ KIND │ NAME │ NAMESPACE │
163+
├───────────────────────────┼──────────────────────┼────────────────────────────────┼──────────────────────────────┤
164+
│ │ Namespace │ istio-system │ │
165+
│ │ Namespace │ config-management-monitoring │ │
166+
│ constraints.gatekeeper.sh │ K8sRequiredLabels │ deployment-required-labels │ │
167+
│ constraints.gatekeeper.sh │ K8sRequiredLabels │ namespace-required-labels │ │
168+
│ constraints.gatekeeper.sh │ K8sAllowedRepos │ allowed-container-registries │ │
169+
│ networking.gke.io │ NetworkLogging │ default │ │
170+
| rbac.authorization.k8s.io │ ClusterRole │ custom:aggregate-to-edit:istio │ │
171+
│ templates.gatekeeper.sh │ ConstraintTemplate │ k8sallowedrepos │ │
172+
│ templates.gatekeeper.sh │ ConstraintTemplate │ k8srequiredlabels │ │
173+
│ │ ServiceAccount │ default │ config-management-monitoring │
174+
│ security.istio.io │ AuthorizationPolicy │ deny-all │ istio-system │
175+
│ │ ConfigMap │ istio-asm-managed-rapid │ istio-system │
176+
│ mesh.cloud.google.com │ ControlPlaneRevision │ asm-managed-rapid │ istio-system │
177+
│ security.istio.io │ PeerAuthentication │ default │ istio-system │
178+
└───────────────────────────┴──────────────────────┴────────────────────────────────┴──────────────────────────────┘
151179
```

content/whereami/set-up-whereami-git-repo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ subjects:
7979
namespace: config-management-system
8080
roleRef:
8181
kind: ClusterRole
82-
name: cluster-admin
82+
name: edit
8383
apiGroup: rbac.authorization.k8s.io
8484
EOF
8585
```
86-
{{% notice info %}}
87-
We are using the `cluster-admin` role here, but in the future we will change this with a least privilege approach. It will be something with `edit` role and the the Istio resources like `VirtualService`, etc. leveraged in this workshop. See [more information about the user-facing roles here](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles).
86+
{{% notice tip %}}
87+
We are using the [`edit` user-facing role](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles) here, to follow the least privilege principle. Earlier in this workshop during the ASM installation, we extended the default `edit` role with more capabilities regarding to the Istio resources: `VirtualService`, `Sidecar` and `Authorization` wich will be leveraged in the Whereami's namespace.
8888
{{% /notice %}}
8989

9090
## Deploy Kubernetes manifests

0 commit comments

Comments
 (0)