add role and validation policy for namespaces
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: edit-namespaces
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["namespaces"]
|
||||||
|
verbs: ["create", "get", "list", "watch", "update", "patch", "delete"]
|
||||||
---
|
---
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
@@ -10,4 +18,17 @@ subjects:
|
|||||||
roleRef:
|
roleRef:
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
name: ontime-operator-stage-editor-role
|
name: ontime-operator-stage-editor-role
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: edit-namespaces-clusterrolebinding
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: stage-editor
|
||||||
|
namespace: stage-maker
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: edit-namespaces
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: stage-maker
|
|
||||||
namespace: stage-maker
|
|
||||||
labels:
|
|
||||||
app: stage-maker
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: stage-maker
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: stage-maker
|
|
||||||
spec:
|
|
||||||
serviceAccountName: stage-editor
|
|
||||||
volumes:
|
|
||||||
- name: storage
|
|
||||||
nfs:
|
|
||||||
path: /volume1/docker/ontime-k8s
|
|
||||||
server: 10.0.0.17
|
|
||||||
containers:
|
|
||||||
- name: stage-maker
|
|
||||||
image: git.jwetzell.com/jwetzell/stage-maker:v0.0.18
|
|
||||||
env:
|
|
||||||
- name: ONTIME_HOSTNAME
|
|
||||||
value: "ontime.jwetzell.com"
|
|
||||||
- name: NFS_SERVER
|
|
||||||
value: "10.0.0.17"
|
|
||||||
- name: NFS_BASE_PATH
|
|
||||||
value: "/volume1/docker/ontime-k8s"
|
|
||||||
- name: STORAGE_BASE_PATH
|
|
||||||
value: "/data"
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: "1024Mi"
|
|
||||||
requests:
|
|
||||||
cpu: 1000m
|
|
||||||
memory: "512Mi"
|
|
||||||
volumeMounts:
|
|
||||||
- name: storage
|
|
||||||
mountPath: "/data"
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
name: stage-maker-ingress
|
|
||||||
namespace: stage-maker
|
|
||||||
spec:
|
|
||||||
ingressClassName: nginx
|
|
||||||
rules:
|
|
||||||
- host: ontime.jwetzell.com
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- path: /api/v1/stage
|
|
||||||
pathType: Prefix
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: stage-maker-service
|
|
||||||
port:
|
|
||||||
number: 3000
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- namespace.yaml
|
|
||||||
- deployment.yaml
|
|
||||||
- ingress.yaml
|
|
||||||
- cluster-role-binding.yaml
|
- cluster-role-binding.yaml
|
||||||
|
- namespace-prefix-policy.yaml
|
||||||
|
- namespace.yaml
|
||||||
- service-account.yaml
|
- service-account.yaml
|
||||||
- service.yaml
|
|
||||||
|
|||||||
31
apps/stage-maker/namespace-prefix-policy.yaml
Normal file
31
apps/stage-maker/namespace-prefix-policy.yaml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: admissionregistration.k8s.io/v1alpha1
|
||||||
|
kind: ValidatingAdmissionPolicy
|
||||||
|
metadata:
|
||||||
|
name: "force-ns-prefix-for-stage-editor"
|
||||||
|
spec:
|
||||||
|
failurePolicy: Fail
|
||||||
|
matchConstraints:
|
||||||
|
resourceRules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
apiVersions: ["v1"]
|
||||||
|
operations: ["CREATE", "UPDATE"]
|
||||||
|
resources: ["namespaces"]
|
||||||
|
matchConditions:
|
||||||
|
- name: 'only-stage-editor'
|
||||||
|
value: "request.userInfo.username == 'system:serviceaccount:stage-maker:stage-editor'"
|
||||||
|
validations:
|
||||||
|
- expression: "object.metadata.namespace.startsWith('team-')"
|
||||||
|
message: "All namespace requests by stage-editor must start with 'team-'"
|
||||||
|
---
|
||||||
|
apiVersion: admissionregistration.k8s.io/v1alpha1
|
||||||
|
kind: ValidatingAdmissionPolicyBinding
|
||||||
|
metadata:
|
||||||
|
name: "force-ns-prefix-for-stage-editor-binding"
|
||||||
|
spec:
|
||||||
|
policyName: "force-ns-prefix-for-stage-editor"
|
||||||
|
matchResources:
|
||||||
|
resourceRules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
apiVersions: ["v1"]
|
||||||
|
operations: ["CREATE", "UPDATE"]
|
||||||
|
resources: ["namespaces"]
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: stage-maker-service
|
|
||||||
namespace: stage-maker
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: stage-maker
|
|
||||||
ports:
|
|
||||||
- protocol: "TCP"
|
|
||||||
port: 3000
|
|
||||||
targetPort: 3000
|
|
||||||
name: web
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user