Skip to content

Commit

Permalink
Merge pull request #690 from kloudmax/main
Browse files Browse the repository at this point in the history
update KubeArmorAnnotation
  • Loading branch information
nam-jaehyun authored May 11, 2022
2 parents 84c0166 + 9b558c4 commit e53fac7
Show file tree
Hide file tree
Showing 11 changed files with 5,874 additions and 95 deletions.
5,390 changes: 5,390 additions & 0 deletions deployments/annotations/cert-manager.yaml

Large diffs are not rendered by default.

314 changes: 314 additions & 0 deletions deployments/annotations/kubearmor-annotation-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
control-plane: controller-manager
name: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubearmor-annotation-controller-manager
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: kubearmor-annotation-leader-election-role
namespace: kube-system
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: kubearmor-annotation-manager-role
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kubearmor-annotation-metrics-reader
rules:
- nonResourceURLs:
- /metrics
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kubearmor-annotation-proxy-role
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kubearmor-annotation-leader-election-rolebinding
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: kubearmor-annotation-leader-election-role
subjects:
- kind: ServiceAccount
name: kubearmor-annotation-controller-manager
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubearmor-annotation-manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubearmor-annotation-manager-role
subjects:
- kind: ServiceAccount
name: kubearmor-annotation-controller-manager
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubearmor-annotation-proxy-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubearmor-annotation-proxy-role
subjects:
- kind: ServiceAccount
name: kubearmor-annotation-controller-manager
namespace: kube-system
---
apiVersion: v1
data:
controller_manager_config.yaml: |
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
kind: ControllerManagerConfig
health:
healthProbeBindAddress: :8081
metrics:
bindAddress: 127.0.0.1:8080
webhook:
port: 9443
leaderElection:
leaderElect: true
resourceName: d6ccf1e6.kubearmor.com
kind: ConfigMap
metadata:
name: kubearmor-annotation-manager-config
namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
labels:
control-plane: controller-manager
name: kubearmor-annotation-controller-manager-metrics-service
namespace: kube-system
spec:
ports:
- name: https
port: 8443
targetPort: https
selector:
control-plane: controller-manager
---
apiVersion: v1
kind: Service
metadata:
name: kubearmor-annotation-webhook-service
namespace: kube-system
spec:
ports:
- port: 443
protocol: TCP
targetPort: 9443
selector:
control-plane: controller-manager
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
control-plane: controller-manager
name: kubearmor-annotation-controller-manager
namespace: kube-system
spec:
replicas: 2
selector:
matchLabels:
control-plane: controller-manager
template:
metadata:
annotations:
container.apparmor.security.beta.kubernetes.io/manager: unconfined
labels:
control-plane: controller-manager
spec:
containers:
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
command:
- /manager
image: kubearmor/kubearmor-annotation-manager:latest
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
name: manager
ports:
- containerPort: 9443
name: webhook-server
protocol: TCP
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: 100m
memory: 30Mi
requests:
cpu: 100m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
- mountPath: /sys/kernel/security
name: sys-path
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: https
serviceAccountName: kubearmor-annotation-controller-manager
terminationGracePeriodSeconds: 10
volumes:
- name: cert
secret:
defaultMode: 420
secretName: webhook-server-cert
- hostPath:
path: /sys/kernel/security
type: Directory
name: sys-path
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: kubearmor-annotation-serving-cert
namespace: kube-system
spec:
dnsNames:
- kubearmor-annotation-webhook-service.kube-system.svc
- kubearmor-annotation-webhook-service.kube-system.svc.cluster.local
issuerRef:
kind: Issuer
name: kubearmor-annotation-selfsigned-issuer
secretName: webhook-server-cert
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: kubearmor-annotation-selfsigned-issuer
namespace: kube-system
spec:
selfSigned: {}
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: kube-system/kubearmor-annotation-serving-cert
name: kubearmor-annotation-mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: kubearmor-annotation-webhook-service
namespace: kube-system
path: /mutate-pods
failurePolicy: Fail
name: annotation.kubearmor.com
rules:
- apiGroups:
- ""
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
sideEffects: NoneOnDryRun
4 changes: 3 additions & 1 deletion pkg/KubeArmorAnnotation/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
# Copyright 2021 Authors of KubeArmor

# Build the manager binary
FROM golang:1.16 as builder
FROM golang:1.17 as builder

WORKDIR /workspace

# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
Expand Down
Loading

0 comments on commit e53fac7

Please sign in to comment.