Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolmo committed Dec 17, 2021
1 parent 85d9d73 commit 96722e2
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 24 deletions.
2 changes: 1 addition & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace: lvm-operator-system
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: lvm-operator-
# namePrefix: lvm-operator-

# Labels to add to all resources and selectors.
#commonLabels:
Expand Down
6 changes: 5 additions & 1 deletion config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ resources:
- service_account.yaml
- role.yaml
- role_binding.yaml
- sccs.yaml
- leader_election_role.yaml
- leader_election_role_binding.yaml
# topolvm-node rbac
- topolvm_node_service_account.yaml
- topolvm_node_scc.yaml
- topolvm_node_role.yaml
- topolvm_node_role_bindings.yaml
# Comment the following 4 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
Expand Down
13 changes: 0 additions & 13 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,3 @@ subjects:
- kind: ServiceAccount
name: controller-manager
namespace: system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: topolvm-node-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: manager-role
subjects:
- kind: ServiceAccount
name: node-manager
namespace: system
6 changes: 0 additions & 6 deletions config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ kind: ServiceAccount
metadata:
name: controller-manager
namespace: system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: node-manager
namespace: system
45 changes: 45 additions & 0 deletions config/rbac/topolvm_node_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: topolvm-node
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- update
- patch
- apiGroups:
- topolvm.cybozu.com
resources:
- logicalvolumes
- logicalvolumes/status
verbs:
- get
- list
- watch
- create
- update
- delete
- patch
- apiGroups:
- storage.k8s.io
resources:
- csidrivers
verbs:
- get
- list
- watch
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- use
resourceNames:
- privileged
#- topolvm-node TODO: this scc (topolvm-node) does not provide all the rights needed .. why?
13 changes: 13 additions & 0 deletions config/rbac/topolvm_node_role_bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: topolvm-node
subjects:
- kind: ServiceAccount
name: node-manager
namespace: system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: topolvm-node

23 changes: 23 additions & 0 deletions config/rbac/topolvm_node_scc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: SecurityContextConstraints
apiVersion: security.openshift.io/v1
metadata:
name: topolvm-node
allowHostDirVolumePlugin: true
allowHostIPC: true
allowHostNetwork: true
allowHostPID: true
allowHostPorts: true
allowPrivilegeEscalation: true
allowPrivilegedContainer: true
readOnlyRootFilesystem: false
volumes:
- emptyDir
- hostPath
runAsUser:
type: RunAsAny
seLinuxContext:
type: RunAsAny
fsGroup:
type: RunAsAny
supplementalGroups:
type: RunAsAny
5 changes: 5 additions & 0 deletions config/rbac/topolvm_node_service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: node-manager
namespace: system
10 changes: 7 additions & 3 deletions controllers/topolvm_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,14 @@ func getInitContainer() *corev1.Container {
fmt.Sprintf("until [ -f %s ]; do echo waiting for lvmd config file; sleep 5; done", lvmdConfigFile),
}

volumeMounts := []corev1.VolumeMount{
{Name: "lvmd-config-dir", MountPath: "/etc/topolvm"}}

fileChecker := &corev1.Container{
Name: "file-checker",
Image: auxImage,
Command: command,
Name: "file-checker",
Image: auxImage,
Command: command,
VolumeMounts: volumeMounts,
}

return fileChecker
Expand Down

0 comments on commit 96722e2

Please sign in to comment.