Skip to content

Commit

Permalink
Re-add namespace self provisioning
Browse files Browse the repository at this point in the history
This was removed by accident in #207.
  • Loading branch information
bastjan committed Sep 19, 2024
1 parent 5932082 commit 439069e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
44 changes: 44 additions & 0 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,46 @@ local namespaceAnnotations = (

local secrets = com.generateResources(params.secrets, function(name) com.namespaced(params.namespace, kube.Secret(name) + common.DefaultLabels));

/**
* appuio-ns-provisioner role allows to create namespaces
*/
local appuioNsProvisionerRole = kube.ClusterRole('appuio-ns-provisioner') {
rules: [
{
apiGroups: [
'',
],
resources: [
'namespaces',
],
verbs: [
'create',
],
},
],
};

/**
* appuio-ns-provisioners cluster role binding allows authenticated users to create namespaces
*/
local appuioNsProvisionersRoleBinding = kube.ClusterRoleBinding('appuio-ns-provisioners') {
roleRef: {
apiGroup: 'rbac.authorization.k8s.io',
kind: 'ClusterRole',
name: 'appuio-ns-provisioner',
},
subjects: [
{
kind: 'Group',
name: 'system:authenticated:oauth',
},
{
kind: 'Group',
name: 'system:serviceaccounts',
},
],
};

{
'00_namespace': kube.Namespace(params.namespace) {
metadata+: {
Expand All @@ -27,4 +67,8 @@ local secrets = com.generateResources(params.secrets, function(name) com.namespa
},
} + common.DefaultLabels,
'00_secrets': secrets,

'01_appuio_ns_provisioner_role': appuioNsProvisionerRole + common.DefaultLabels,
'01_appuio_ns_provisioners_crb': appuioNsProvisionersRoleBinding + common.DefaultLabels,

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
app.kubernetes.io/component: appuio-cloud
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: appuio-cloud
name: appuio-ns-provisioner
name: appuio-ns-provisioner
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- create
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations: {}
labels:
app.kubernetes.io/component: appuio-cloud
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: appuio-cloud
name: appuio-ns-provisioners
name: appuio-ns-provisioners
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: appuio-ns-provisioner
subjects:
- kind: Group
name: system:authenticated:oauth
- kind: Group
name: system:serviceaccounts

0 comments on commit 439069e

Please sign in to comment.