Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
More restrictive RBAC for CICD user
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasK33 committed Feb 5, 2021
1 parent 3eabab7 commit 9ab41e1
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions devops/kubernetes/src/charts/cicd-user/cicdUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Construct } from "constructs";
import {
KubeServiceAccount,
KubeRoleBinding,
KubeClusterRole,
KubeRole,
} from "../../../imports/k8s";

export class CICDUser extends Chart {
Expand All @@ -17,9 +17,10 @@ export class CICDUser extends Chart {
automountServiceAccountToken: false,
});

new KubeClusterRole(this, "role", {
new KubeRole(this, "role-fortify-ns", {
metadata: {
name: "cicd-user-role",
namespace: "fortify",
},
rules: [
{
Expand Down Expand Up @@ -76,6 +77,19 @@ export class CICDUser extends Chart {
},
],
});
new KubeRole(this, "role-kube-system-ns", {
metadata: {
name: "cicd-user-role",
namespace: "kube-system",
},
rules: [
{
apiGroups: ["traefik.containo.us"],
resources: ["ingressroutes"],
verbs: ["create", "delete", "list", "get", "patch"],
},
],
});

new KubeRoleBinding(this, "role-binding-fortify", {
metadata: {
Expand All @@ -91,11 +105,10 @@ export class CICDUser extends Chart {
],
roleRef: {
apiGroup: "rbac.authorization.k8s.io",
kind: "ClusterRole",
kind: "Role",
name: "cicd-user-role",
},
});

new KubeRoleBinding(this, "role-binding-kube-system", {
metadata: {
name: "cicd-user-kube-system-rolebinding",
Expand All @@ -110,7 +123,7 @@ export class CICDUser extends Chart {
],
roleRef: {
apiGroup: "rbac.authorization.k8s.io",
kind: "ClusterRole",
kind: "Role",
name: "cicd-user-role",
},
});
Expand Down

0 comments on commit 9ab41e1

Please sign in to comment.