Anda dapat mengonfigurasi kebijakan keamanan untuk pod guna memverifikasi keamanan permintaan saat menerapkan atau memperbarui pod. Fitur manajemen kebijakan kluster Alibaba Cloud Container Compute Service (ACS) menyediakan empat pustaka aturan bawaan: Compliance, Infra, K8s-general, dan PSP.
Informasi latar belakang
ACS menyediakan jenis-jenis kebijakan keamanan bawaan berikut:
Compliance: Kebijakan keamanan ini disesuaikan berdasarkan standar kepatuhan seperti Pengerasan Keamanan Kubernetes Alibaba Cloud.
Infra: Kebijakan keamanan ini digunakan untuk memastikan dan meningkatkan keamanan sumber daya infrastruktur cloud.
K8s-general: Kebijakan keamanan ini digunakan untuk membatasi dan menormalisasi konfigurasi sumber daya sensitif dalam kluster ACS serta meningkatkan keamanan aplikasi di dalam kluster.
PSP: Kebijakan keamanan ini dapat digunakan sebagai pengganti kebijakan keamanan pod (PSP) Kubernetes open source dan memberikan kemampuan kontrol akses yang sama.
Kebijakan keamanan bawaan
Tabel berikut menjelaskan kebijakan keamanan bawaan ACS.
Kategori | Kebijakan | Deskripsi | Tingkat Keparahan |
Compliance |
| Parameter secretKeyRef tidak dapat digunakan untuk mereferensikan Secrets saat Anda menentukan variabel lingkungan pod. | sedang |
| Pod di namespace tertentu harus dikonfigurasi dengan parameter | rendah | |
| Sumber daya tipe tertentu tidak dapat diterapkan di namespace tertentu. | rendah | |
| RoleBindings di namespace tertentu hanya dapat digunakan untuk mengikat peran atau cluster role tertentu. | tinggi | |
| Namespace tertentu tidak dapat dihapus. | sedang | |
| Instance Layanan di namespace tertentu tidak dapat dihapus. | sedang | |
Infra |
| Pod di namespace tertentu tidak dapat dikonfigurasi dengan parameter shareProcessNamespace. | tinggi |
| Parameter | rendah | |
| Pod di namespace tertentu harus dikonfigurasi dengan anotasi | rendah | |
| Bucket Object Storage Service (OSS) di wilayah tertentu dapat dipasang ke pod di namespace tertentu. | rendah | |
| Menentukan kapasitas disk maksimum yang dapat diminta untuk Persistent Volume (PV) yang dibuat di kluster ACS. | sedang | |
| Menentukan namespace tempat Persistent Volume Claims (PVC) dapat diterapkan dan kapasitas disk maksimum yang dapat diminta untuk PV. | sedang | |
K8s-general |
| Pod di namespace tertentu hanya dapat menarik gambar dari repositori gambar yang ditentukan. | tinggi |
| Pod di namespace tertentu harus dikonfigurasi dengan | rendah | |
| Pod di namespace tertentu harus dikonfigurasi dengan | tinggi | |
| Pod di namespace tertentu tidak dapat meluncurkan kontainer sementara. | sedang | |
| Layanan LoadBalancer tidak dapat diterapkan di namespace tertentu. | tinggi | |
| Pod di namespace tertentu harus dikonfigurasi dengan batasan sumber daya | rendah | |
| Layanan di namespace tertentu tidak dapat menggunakan alamat IP eksternal yang tidak ditentukan dalam isi kebijakan. | tinggi | |
| Pod di namespace tertentu harus diterapkan dari gambar yang digest-nya sesuai dengan format yang ditentukan. | rendah | |
| Pod di namespace tertentu harus memiliki label yang sesuai dengan isi kebijakan. | rendah | |
| Pod di namespace tertentu harus dikonfigurasi dengan jenis probe kesiapan dan probe kelangsungan hidup yang ditentukan. | sedang | |
| Parameter | tinggi | |
| Layanan LoadBalancer yang menghadap internet tidak dapat dibuat. | tinggi | |
PSP |
| Pod di namespace tertentu harus dikonfigurasi dengan parameter | sedang |
| Pod di namespace tertentu harus dikonfigurasi dengan pengaturan | sedang | |
| Pod di namespace tertentu harus dikonfigurasi dengan pengaturan AppArmor. | rendah | |
| Pod di namespace tertentu harus dikonfigurasi dengan pengaturan Linux Capabilities. | tinggi | |
| Pod di namespace tertentu harus dikonfigurasi dengan pengaturan fsGroup yang sesuai dengan isi kebijakan. | sedang | |
| Pod di namespace tertentu tidak dapat menggunakan driver FlexVolume yang tidak ditentukan dalam isi kebijakan. | sedang | |
| Pod di namespace tertentu tidak dapat menggunakan sysctl yang ditentukan. | tinggi | |
| Volume hostPath yang dipasang ke pod di namespace tertentu harus memenuhi kondisi yang ditentukan. | tinggi | |
| Pod di namespace tertentu tidak dapat menjalankan kontainer istimewa. | tinggi | |
| Pod di namespace tertentu harus berjalan dengan sistem file root hanya-baca. | sedang | |
| Pod di namespace tertentu tidak dapat dikonfigurasi dengan opsi SELinux yang tidak ditentukan dalam isi kebijakan. | rendah | |
| Pod di namespace tertentu harus dikonfigurasi dengan profil seccomp yang ditentukan. | rendah | |
| Hanya volume tipe tertentu yang dapat dipasang ke pod di namespace tertentu. | sedang |
Compliance
ACKNoEnvVarSecrets
Deskripsi Kebijakan: Parameter secretKeyRef tidak dapat digunakan untuk mereferensikan Secrets saat Anda menentukan variabel lingkungan pod.
Tingkat Keparahan: Sedang
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKNoEnvVarSecrets metadata: name: no-env-var-secrets spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: ["test-gatekeeper"]Diizinkan:
apiVersion: v1 kind: Pod metadata: name: mypod namespace: test-gatekeeper spec: containers: - name: mypod image: testimage volumeMounts: - name: foo mountPath: "/etc/foo" volumes: - name: foo secret: secretName: mysecret items: - key: username path: my-group/my-usernameTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad namespace: test-gatekeeper spec: containers: - name: mycontainer image: testimage env: - name: SECRET_USERNAME valueFrom: secretKeyRef: name: mysecret key: username - name: SECRET_PASSWORD valueFrom: secretKeyRef: name: mysecret key: password restartPolicy: NeverACKPodsRequireSecurityContext
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan parameter
securityContext.Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPodsRequireSecurityContext metadata: name: pods-require-security-context annotations: description: "Requires that Pods must have a `securityContext` defined." spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: ["test-gatekeeper"]Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: test namespace: test-gatekeeper spec: securityContext: runAsNonRoot: false containers: - image: test name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Never status: {}Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: non-test-gatekeeper spec: containers: - image: testimage name: test2 - image: testimage name: test resources: {} securityContext: runAsNonRoot: falseACKRestrictNamespaces
Deskripsi Kebijakan: Sumber daya tipe tertentu tidak dapat diterapkan di namespace yang ditentukan.
Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
restrictedNamespaces
array
Menentukan nama namespace tempat sumber daya tidak dapat diterapkan.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKRestrictNamespaces metadata: name: restrict-default-namespace annotations: description: "Restricts resources from using the restricted namespace." spec: match: kinds: - apiGroups: [''] kinds: ['Pod'] parameters: restrictedNamespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: test namespace: non-test-gatekeeper spec: containers: - image: test name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Never status: {}Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad namespace: test-gatekeeper spec: containers: - name: mycontainer image: testimage restartPolicy: NeverACKRestrictRoleBindings
Deskripsi Kebijakan: Rolebindings di namespace tertentu hanya dapat digunakan untuk mengikat peran atau cluster role tertentu yang ditentukan.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
restrictedRole
object
Menentukan cluster roles atau roles yang tidak diizinkan untuk ditetapkan.
allowedSubjects
array
Menentukan subjek yang dapat dipasang.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKRestrictRoleBindings metadata: name: restrict-clusteradmin-rolebindings annotations: description: "Restricts use of sensitive role in specific rolebinding." spec: match: kinds: - apiGroups: ["rbac.authorization.k8s.io"] kinds: ["RoleBinding"] parameters: restrictedRole: apiGroup: "rbac.authorization.k8s.io" kind: "ClusterRole" name: "cluster-admin" allowedSubjects: - apiGroup: "rbac.authorization.k8s.io" kind: "Group" name: "system:masters"Diizinkan:
kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: good-2 namespace: test-gatekeeper subjects: - kind: Group name: 'system:masters' roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.ioTidak Diizinkan:
kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: bad-1 namespace: test-gatekeeper subjects: - kind: ServiceAccount name: policy-template-controller roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.ioACKNamespacesDeleteProtection
Deskripsi Kebijakan: Namespace yang ditentukan tidak dapat dihapus. Anda dapat menyetel parameter
protectionNamespaceske nama namespace yang tidak dapat dihapus.Untuk mengaktifkan kebijakan ini, Anda harus menggunakan gatekeeper 3.10.0.130-g0e79597d-aliyun atau versi lebih baru. Untuk informasi lebih lanjut tentang versi gatekeeper, lihat gatekeeper.
Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
protectionNamespaces
array
Nama namespace yang tidak dapat dihapus.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKNamespacesDeleteProtection metadata: name: namespace-delete-protection spec: match: kinds: - apiGroups: [''] kinds: ['Namespace'] parameters: protectionNamespaces: - test-gatekeeperDiizinkan:
apiVersion: v1 kind: Namespace metadata: name: will-deleteTidak Diizinkan:
apiVersion: v1 kind: Namespace metadata: name: test-gatekeeperACKServicesDeleteProtection
Deskripsi Kebijakan: Instance Layanan di namespace tertentu tidak dapat dihapus. Anda dapat menyetel parameter
protectionServiceske nama instance Layanan yang tidak dapat dihapus.Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
protectionServices
array
Nama instance Layanan di namespace tertentu yang tidak dapat dihapus.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKServicesDeleteProtection metadata: name: service-delete-protection annotations: description: "Protect to delete specific service." spec: enforcementAction: deny match: kinds: - apiGroups: [''] kinds: ['Service'] namespaces: ["test-gatekeeper"] parameters: protectionServices: - test-svcDiizinkan:
apiVersion: v1 kind: Service metadata: name: good namespace: test-gatekeeperTidak Diizinkan:
apiVersion: v1 kind: Service metadata: name: test-svc
Infra
ACKBlockProcessNamespaceSharing
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat dikonfigurasi dengan parameter
shareProcessNamespace.Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockProcessNamespaceSharing ACKCheckNginxPathmetadata: name: block-share-process-namespace spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: ["test-gatekeeper"]Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: test-3 namespace: test-gatekeeper spec: containers: - image: test name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Never status: {}Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: shareProcessNamespace: true containers: - image: test name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Never status: {}ACKEmptyDirHasSizeLimit
Deskripsi Kebijakan: Parameter
sizelimitharus dikonfigurasikan saat Anda memasang volume emptyDir.Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKEmptyDirHasSizeLimit metadata: name: empty-dir-has-sizelimit spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: ["test-gatekeeper"]Diizinkan:
apiVersion: v1 kind: Pod metadata: name: test-1 namespace: test-gatekeeper spec: containers: - image: test name: test-container volumeMounts: - mountPath: /cache name: cache-volume volumes: - name: cache-volume emptyDir: sizeLimit: "10Mi"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad namespace: test-gatekeeper spec: containers: - image: test name: test-container volumeMounts: - mountPath: /cache name: cache-volume volumes: - name: cache-volume emptyDir: {}ACKLocalStorageRequireSafeToEvict
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan anotasi
"cluster-autoscaler.kubernetes.io/safe-to-evict": "true". Pod yang tidak dikonfigurasi dengan anotasi ini tidak akan dihapus selama aktivitas penskalaan.Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKLocalStorageRequireSafeToEvict metadata: name: local-storage-require-safe-to-evict spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: ["test-gatekeeper"]Diizinkan:
apiVersion: v1 kind: Pod metadata: name: test-1 namespace: test-gatekeeper annotations: 'cluster-autoscaler.kubernetes.io/safe-to-evict': 'true' spec: containers: - image: test name: test-container volumeMounts: - mountPath: /test-pd name: test-volume volumes: - name: test-volume hostPath: # lokasi direktori pada host path: /data # bidang ini opsional type: DirectoryTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad namespace: test-gatekeeper spec: containers: - image: test name: test-container volumeMounts: - mountPath: /cache name: cache-volume volumes: - name: cache-volume emptyDir: {}ACKOSSStorageLocationConstraint
Deskripsi Kebijakan: Menentukan apakah bucket OSS di wilayah tertentu dapat dipasang ke pod di namespace tertentu.
Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
mode
string
Menentukan apakah mode daftar putih diaktifkan. Nilai default:
allowlist, yang menunjukkan bahwa mode daftar putih diaktifkan. Nilai lainnya menunjukkan bahwa mode daftar hitam diaktifkan.regions
array
ID wilayah yang ditentukan.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKOSSStorageLocationConstraint metadata: name: restrict-oss-location annotations: description: "Restricts location of oss storage in cluster." spec: match: kinds: - apiGroups: [''] kinds: ['PersistentVolume', 'Pod'] namespaces: ["test-gatekeeper"] parameters: mode: "allowlist" regions: - "cn-beijing"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-oss-csi-good namespace: test-gatekeeper spec: containers: - name: test image: test volumes: - name: test csi: driver: ossplugin.csi.alibabacloud.com volumeAttributes: bucket: "oss" url: "oss-cn-beijing.aliyuncs.com" otherOpts: "-o max_stat_cache_size=0 -o allow_other" path: "/"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-oss-csi namespace: test-gatekeeper spec: containers: - name: test image: test volumes: - name: test csi: driver: ossplugin.csi.alibabacloud.com volumeHandle: pv-oss nodePublishSecretRef: name: oss-secret namespace: default volumeAttributes: bucket: "oss" url: "oss-cn-hangzhou.aliyuncs.com" otherOpts: "-o max_stat_cache_size=0 -o allow_other" path: "/"ACKPVSizeConstraint
Deskripsi Kebijakan: Menentukan kapasitas disk maksimum yang dapat diminta untuk PV yang dibuat dalam kluster ACS.
Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
maxSize
string
Kapasitas disk maksimum yang dapat diminta untuk PV dalam kluster ACS. Nilai default: 50 GiB.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPVSizeConstraint metadata: name: limit-pv-size annotations: description: "Limit the pv storage capacity size within a specified maximum amount." spec: enforcementAction: deny match: kinds: - apiGroups: [ "" ] kinds: [ "PersistentVolume" ] parameters: maxSize: "50Gi"Diizinkan:
apiVersion: v1 kind: PersistentVolume metadata: name: pv-oss-csi labels: alicloud-pvname: pv-oss spec: capacity: storage: 25Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain csi: driver: ossplugin.csi.alibabacloud.com volumeHandle: pv-oss nodePublishSecretRef: name: oss-secret namespace: default volumeAttributes: bucket: "oss" url: "oss-cn-beijing.aliyuncs.com" otherOpts: "-o max_stat_cache_size=0 -o allow_other" path: "/"Tidak Diizinkan:
apiVersion: v1 kind: PersistentVolume metadata: name: pv-oss-csi-bad labels: alicloud-pvname: pv-oss spec: capacity: storage: 500Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain csi: driver: ossplugin.csi.alibabacloud.com volumeHandle: pv-oss nodePublishSecretRef: name: oss-secret namespace: default volumeAttributes: bucket: "oss" url: "oss-cn-beijing.aliyuncs.com" otherOpts: "-o max_stat_cache_size=0 -o allow_other" path: "/"ACKPVCConstraint
Deskripsi Kebijakan: Menentukan namespace tempat PVC dapat diterapkan dan kapasitas disk maksimum yang dapat diminta untuk PV.
Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
maxSize
string
Kapasitas disk maksimum yang dapat diminta untuk PV. Nilai default: 50 GiB.
allowNamespaces
array
Nama namespace tempat PVC dapat diterapkan.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPVCConstraint metadata: name: limit-pvc-size-and-ns annotations: description: "Limit the maximum pvc storage capacity size and the namespace whitelists that can be deployed." spec: enforcementAction: deny match: kinds: - apiGroups: [ "" ] kinds: [ "PersistentVolumeClaim" ] parameters: maxSize: "50Gi" allowNamespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: disk-pvc namespace: test-gatekeeper spec: accessModes: - ReadWriteOnce resources: requests: storage: 20GiTidak Diizinkan:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: bad-disk-pvc namespace: test-gatekeeper spec: accessModes: - ReadWriteOnce resources: requests: storage: 200Gi --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: bad-namespace-pvc namespace: test-gatekeeper-bad spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi
K8s-general
ACKAllowedRepos
Deskripsi Kebijakan: Pod di namespace tertentu hanya dapat menarik gambar dari repositori gambar yang ditentukan.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
repos
Larik
Menentukan repositori gambar dari mana pod dapat menarik gambar.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKAllowedRepos metadata: name: allowed-repos spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: repos: - "registry-vpc.cn-hangzhou.aliyuncs.com/acs/" - "registry.cn-hangzhou.aliyuncs.com/acs/"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-01 namespace: test-gatekeeper spec: containers: - image: registry.cn-hangzhou.aliyuncs.com/acs/test-webserver name: test-container-1 initContainers: - image: registry.cn-hangzhou.aliyuncs.com/acs/test-webserver name: test-containerTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad-1 namespace: test-gatekeeper spec: containers: - image: test name: test-container initContainers: - image: test name: test-container-3ACKBlockAutoinjectServiceEnv
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan
enableServiceLinks: false, yang menentukan bahwa alamat IP Layanan tidak disuntikkan ke variabel lingkungan pod.Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockAutoinjectServiceEnv metadata: name: block-auto-inject-service-env spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-0 namespace: test-gatekeeper spec: enableServiceLinks: false containers: - image: openpolicyagent/test-webserver:1.0 name: test-containerTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad-1 namespace: test-gatekeeper spec: containers: - image: test name: test-containerACKBlockAutomountToken
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan
automountServiceAccountToken: false, yang menentukan bahwaservice accountstidak secara otomatis dipasang.Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockAutomountToken metadata: name: block-auto-mount-service-account-token spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-0 namespace: test-gatekeeper spec: automountServiceAccountToken: false containers: - image: openpolicyagent/test-webserver:v1.0 name: test-containerTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad-1 namespace: test-gatekeeper spec: containers: - image: test name: test-containerACKBlockEphemeralContainer
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat meluncurkan kontainer sementara.
Tingkat Keparahan: Sedang
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockEphemeralContainer metadata: name: block-ephemeral-container spec: enforcementAction: deny match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: good-1 namespace: test-gatekeeper spec: containers: - name: mycontainer image: testimageTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad-1 namespace: non-test-gatekeeper spec: containers: - name: mycontainer image: testimage ephemeralContainers: - name: test image: testACKBlockLoadBalancer
Deskripsi Kebijakan: Layanan LoadBalancer tidak dapat diterapkan di namespace tertentu.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
restrictedNamespaces
array
Menentukan nama namespace tempat sumber daya tidak dapat diterapkan.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockLoadBalancer metadata: name: block-load-balancer spec: match: kinds: - apiGroups: [""] kinds: ["Service"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service-1 namespace: test-gatekeeper spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376Tidak Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service namespace: test-gatekeeper spec: type: LoadBalancer selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376ACKBlockNodePort
Deskripsi Kebijakan: Layanan NodePort tidak dapat diterapkan di namespace tertentu.
Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockNodePort metadata: name: block-node-port spec: match: kinds: - apiGroups: [""] kinds: ["Service"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service-1 namespace: test-gatekeeper spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376Tidak Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service namespace: test-gatekeeper spec: type: NodePort selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376ACKContainerLimits
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan batasan sumber daya
limits.Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKContainerLimits metadata: name: container-must-have-limits spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: cpu: "1000m" memory: "1Gi"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-1 namespace: test-gatekeeper spec: containers: - image: openpolicyagent/test-webserver name: test-container resources: limits: memory: "100Mi" cpu: "500m"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-2 namespace: non-test-gatekeeper spec: containers: - image: openpolicyagent/test-webserver name: test-container resources: limits: memory: "100Gi" cpu: "2000m"ACKExternalIPs
Deskripsi Kebijakan: Layanan di namespace tertentu tidak dapat menggunakan
alamat IP eksternalyang tidak ditentukan dalam isi kebijakan.Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedIPs
array
Menentukan
alamat IP eksternalyang dapat digunakan.Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKExternalIPs metadata: name: external-ips spec: match: kinds: - apiGroups: [""] kinds: ["Service"] namespaces: - "test-gatekeeper" parameters: allowedIPs: - "192.168.0.5"Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service-3 namespace: test-gatekeeper spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376Tidak Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service namespace: test-gatekeeper spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376 externalIPs: - 80.11.XX.XXACKImageDigests
Deskripsi Kebijakan: Pod di namespace tertentu harus diterapkan dari gambar yang
digestssesuai dengan format yang ditentukan.Tingkat Keparahan: Rendah
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKImageDigests metadata: name: container-image-must-have-digest spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pod-0 namespace: test-gatekeeper spec: containers: - image: openpolicyagent/test-webserver@sha256:12e469267d21d66ac9dcae33a4d3d202ccb2591869270b95d0aad7516c7d075b name: test-containerTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad-1 namespace: test-gatekeeper spec: containers: - image: test name: test-container initContainers: - image: test name: test-container2ACKRequiredLabels
Deskripsi Kebijakan: Pod di namespace tertentu harus memiliki
labelsyang ditentukan oleh parameterallowedRegex.Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedRegex
string
Menentukan label dalam ekspresi reguler.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKRequiredLabels metadata: name: must-have-label-test spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: # message: '' labels: - key: test # value allowedRegex: "^test.*$"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: 'test': 'test_233' name: test namespace: test-gatekeeper spec: containers: - name: mycontainer image: testimageTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: 'test': '233' name: bad2 namespace: test-gatekeeper spec: containers: - name: mycontainer image: testimageACKRequiredProbes
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan jenis
readiness probesdanliveness probesyang ditentukan.Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
probes
array
Menentukan probe yang harus dikonfigurasikan untuk pod. Nilai valid: readinessProbe dan livenessProbe.
probeTypes
array
Menentukan jenis probe yang harus dikonfigurasikan untuk pod. Nilai valid: tcpSocket, httpGet, dan exec.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKRequiredProbes metadata: name: must-have-probes spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: probes: ["readinessProbe", "livenessProbe"] probeTypes: ["tcpSocket", "httpGet", "exec"]Diizinkan:
apiVersion: v1 kind: Pod metadata: name: p4 namespace: test-gatekeeper spec: containers: - name: liveness image: k8s.gcr.io/busybox readinessProbe: exec: command: - cat - /tmp/healthy initialDelaySeconds: 5 periodSeconds: 5 livenessProbe: exec: command: - cat - /tmp/healthy initialDelaySeconds: 5 periodSeconds: 5Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: p1 namespace: test-gatekeeper spec: containers: - name: liveness image: k8s.gcr.io/busyboxACKCheckNginxPath
Kebijakan ini mencegah Anda menggunakan konfigurasi berisiko tinggi di bidang
spec.rules[].http.paths[].pathIngress. Kami sarankan Anda mengaktifkan kebijakan ini untuk Ingress-nginx versi sebelum 1.2.1.Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKCheckNginxPath metadata: name: block-nginx-path spec: enforcementAction: deny match: kinds: - apiGroups: ["extensions", "networking.k8s.io"] kinds: ["Ingress"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: good-paths namespace: test-gatekeeper spec: rules: - host: cafe.example.com http: paths: - path: /tea pathType: Prefix backend: service: name: tea-svc port: number: 80 - path: /coffee pathType: Prefix backend: service: name: coffee-svc port: number: 80Tidak Diizinkan:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: bad-path-secrets namespace: test-gatekeeper spec: rules: - host: cafe.example.com http: paths: - path: /var/run/secrets pathType: Prefix backend: service: name: tea-svc port: number: 80ACKCheckNginxAnnotation
Kebijakan ini mencegah Anda menggunakan konfigurasi berisiko tinggi di bidang metadata.annotations Ingress. Kami sarankan Anda mengaktifkan kebijakan ini untuk Ingress-nginx versi sebelum 1.2.1.
Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKCheckNginxAnnotation metadata: name: block-nginx-annotation spec: match: kinds: - apiGroups: ["extensions", "networking.k8s.io"] kinds: ["Ingress"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: good-annotations namespace: test-gatekeeper annotations: nginx.org/good: "value" spec: rules: - host: cafe.example.com http: paths: - path: /tea pathType: Prefix backend: service: name: tea-svc port: number: 80 - path: /coffee pathType: Prefix backend: service: name: coffee-svc port: number: 80Tidak Diizinkan:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: var-run-secrets namespace: test-gatekeeper annotations: nginx.org/bad: "/var/run/secrets" spec: rules: - host: cafe.example.com http: paths: - path: /tea pathType: Prefix backend: service: name: tea-svc port: number: 80 - path: /coffee pathType: Prefix backend: service: name: coffee-svc port: number: 80ACKBlockInternetLoadBalancer
Deskripsi Kebijakan: Layanan LoadBalancer yang menghadap internet tidak dapat dibuat.
Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKBlockInternetLoadBalancer metadata: name: block-internet-load-balancer spec: match: kinds: - apiGroups: [""] kinds: ["Service"] namespaces: ["test-gatekeeper"]Diizinkan:
apiVersion: v1 kind: Service metadata: name: my-service namespace: non-test-gatekeeper annotations: 'service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type': 'intranet' spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376 type: LoadBalancerTidak Diizinkan:
apiVersion: v1 kind: Service metadata: name: bad-service-2 namespace: test-gatekeeper annotations: 'service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type': 'internet' spec: type: LoadBalancer selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376
PSP
ACKPSPAllowedUsers
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan pengaturan
user,group,supplementalGroups, danfsGroup.Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
runAsUser
object
Untuk informasi lebih lanjut tentang parameter ini, lihat konfigurasi User, tipe aturan yang didukung, dan nilai maksimum serta minimum UID dalam PSP Kubernetes. Untuk informasi lebih lanjut, lihat Users and groups.
runAsGroup
object
Untuk informasi lebih lanjut tentang parameter ini, lihat konfigurasi Group, tipe aturan yang didukung, dan nilai maksimum serta minimum UID dalam PSP Kubernetes. Untuk informasi lebih lanjut, lihat Users and groups.
supplementalGroups
object
Untuk informasi lebih lanjut tentang parameter ini, lihat konfigurasi SupplementalGroups, tipe aturan yang didukung, dan nilai maksimum serta minimum UID dalam PSP Kubernetes. Untuk informasi lebih lanjut, lihat Users and groups.
fsGroup
object
Untuk informasi lebih lanjut tentang parameter ini, lihat konfigurasi fsGroup, tipe aturan yang didukung, dan nilai maksimum serta minimum UID dalam PSP Kubernetes. Untuk informasi lebih lanjut, lihat Users and groups.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPAllowedUsers metadata: name: psp-pods-allowed-user-ranges spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: runAsUser: rule: MustRunAs # MustRunAsNonRoot # RunAsAny ranges: - min: 100 max: 200 runAsGroup: rule: MustRunAs # MayRunAs # RunAsAny ranges: - min: 100 max: 200 supplementalGroups: rule: MustRunAs # MayRunAs # RunAsAny ranges: - min: 100 max: 200 fsGroup: rule: MustRunAs # MayRunAs # RunAsAny ranges: - min: 100 max: 200Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good2 namespace: test-gatekeeper spec: securityContext: fsGroup: 150 supplementalGroups: - 150 containers: - image: test name: test securityContext: runAsUser: 150 runAsGroup: 150Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: containers: - image: test name: testACKPSPAllowPrivilegeEscalationContainer
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan parameter allowPrivilegeEscalation.
Tingkat Keparahan: Sedang
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPAllowPrivilegeEscalationContainer metadata: name: psp-allow-privilege-escalation-container spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: allowPrivilegeEscalation: false initContainers: - image: test name: test2 securityContext: allowPrivilegeEscalation: falseTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: containers: - image: test name: testACKPSPAppArmor
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan pengaturan AppArmor.
Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
probes
array
Menentukan probe yang harus dikonfigurasikan untuk pod. Nilai valid: readinessProbe dan livenessProbe.
probeTypes
array
Menentukan jenis probe yang harus dikonfigurasikan untuk pod. Nilai valid: tcpSocket, httpGet, dan exec.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPAppArmor metadata: name: psp-apparmor spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: allowedProfiles: - runtime/defaultDiizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good namespace: test-gatekeeper annotations: 'container.apparmor.security.beta.kubernetes.io/test': 'runtime/default' 'container.apparmor.security.beta.kubernetes.io/test2': 'runtime/default' spec: containers: - image: test name: test initContainers: - image: test name: test2Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: containers: - image: test name: testACKPSPCapabilities
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan pengaturan Linux Capabilities.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedCapabilities
array
Menentukan capabilities yang dapat dikonfigurasikan untuk pod.
requiredDropCapabilities
array
Menentukan capabilities yang tidak dapat dikonfigurasikan untuk pod.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPCapabilities metadata: name: psp-capabilities spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: allowedCapabilities: ["CHOWN"] requiredDropCapabilities: ["NET_ADMIN", "SYS_ADMIN", "NET_RAW"]Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good-4 namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: capabilities: add: - CHOWN drop: - "NET_ADMIN" - "SYS_ADMIN" - "NET_RAW"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad-1 namespace: test-gatekeeper spec: containers: - image: test name: testACKPSPFlexVolumes
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat menggunakan driver FlexVolume yang tidak ditentukan dalam isi kebijakan.
Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedFlexVolumes
array
Menentukan driver FlexVolume yang dapat digunakan oleh pod.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPFlexVolumes metadata: name: psp-flexvolume-drivers spec: match: kinds: - apiGroups: [""] kinds: ["Pod", "PersistentVolume"] namespaces: - "test-gatekeeper" parameters: allowedFlexVolumes: #[] - driver: "alicloud/disk" - driver: "alicloud/nas" - driver: "alicloud/oss" - driver: "alicloud/cpfs"Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pv-nas namespace: test-gatekeeper spec: containers: - name: test image: test volumes: - name: test flexVolume: driver: "alicloud/nas"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: pv-oss-flexvolume namespace: test-gatekeeper spec: containers: - name: test image: test volumes: - name: test flexVolume: driver: "alicloud/ossxx"ACKPSPForbiddenSysctls
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat menggunakan sysctl yang ditentukan.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
forbiddenSysctls
array
Menentukan sysctl yang tidak dapat digunakan oleh pod.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPForbiddenSysctls metadata: name: psp-forbidden-sysctls spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: forbiddenSysctls: # - "*" # * dapat digunakan untuk melarang semua sysctl - "kernel.*"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good-2 namespace: test-gatekeeper spec: securityContext: sysctls: - name: 'net.ipv4.tcp_syncookies' value: "65536" containers: - image: test name: testTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad-1 namespace: test-gatekeeper spec: securityContext: sysctls: - name: 'kernel.shm_rmid_forced' value: '1024' containers: - image: test name: testACKPSPFSGroup
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan pengaturan fsGroup yang sesuai dengan isi kebijakan.
Tingkat Keparahan: Sedang
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
rule
string
Untuk informasi lebih lanjut tentang parameter ini, lihat konfigurasi fsGroup dalam PSP Kubernetes. Parameter MustRunAs, MayRunAs, dan RunAsAny didukung. Untuk informasi lebih lanjut, lihat Volumes and file systems.
ranges
object
Nilai valid:
min: nilai minimum ID fsGroup.
max: nilai maksimum ID fsGroup.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPFSGroup metadata: name: psp-fsgroup spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: rule: "MayRunAs" #"MustRunAs" #"MayRunAs", "RunAsAny" ranges: - min: 1 max: 1000Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good namespace: test-gatekeeper spec: securityContext: fsGroup: 100 containers: - image: test name: testTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad-1 namespace: non-test-gatekeeper spec: securityContext: fsGroup: 0 shareProcessNamespace: true containers: - image: test name: testACKPSPHostFilesystem
Deskripsi Kebijakan: Volume hostPath yang dipasang ke pod di namespace tertentu harus memenuhi kondisi yang ditentukan.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedHostPaths
object
Menentukan volume hostPath yang dapat dipasang ke pod.
readOnly
boolean
Menentukan apakah volume bersifat hanya-baca.
pathPrefix
string
Menentukan awalan untuk volume.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPHostFilesystem metadata: name: psp-host-filesystem spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: allowedHostPaths: - readOnly: true pathPrefix: "/foo"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good1 namespace: test-gatekeeper spec: containers: - image: test name: test volumeMounts: - name: test-volume mountPath: "/projected-volume" readOnly: true volumes: - name: test-volume hostPath: path: /fooTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: containers: - image: test name: test volumes: - name: test-volume hostPath: path: /data type: FileACKPSPHostNamespace
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat berbagi namespace host.
Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPHostNamespace metadata: name: psp-host-namespace spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good namespace: test-gatekeeper spec: containers: - image: test name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Never status: {}Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: hostPID: true containers: - image: test name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Never status: {}ACKPSPHostNetworkingPorts
Deskripsi Kebijakan: Menentukan apakah pod di namespace tertentu dapat menggunakan jaringan host dan port tertentu.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
hostNetwork
boolean
Menentukan apakah pod dapat menggunakan jaringan host.
min
int
Menentukan nomor port host minimum.
max
int
Menentukan nomor port host tertinggi.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPHostNetworkingPorts metadata: name: psp-host-network-ports spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: hostNetwork: true min: 80 max: 9000Diizinkan:
apiVersion: v1 kind: Pod metadata: name: good-2 namespace: test-gatekeeper spec: hostNetwork: true containers: - image: test name: test-container ports: - hostPort: 80 containerPort: 80 initContainers: - image: test name: test-container2 ports: - hostPort: 8080 containerPort: 8080Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: name: bad-1 namespace: non-test-gatekeeper spec: hostNetwork: true containers: - image: test name: test-container ports: - hostPort: 22 containerPort: 22ACKPSPPrivilegedContainer
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat menjalankan kontainer istimewa.
Tingkat Keparahan: Tinggi
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPPrivilegedContainer metadata: name: psp-privileged-container spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good1 namespace: test-gatekeeper spec: containers: - image: test name: testTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: privileged: true dnsPolicy: ClusterFirst restartPolicy: NeverACKPSPProcMount
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan tipe Proc Mount yang ditentukan dalam isi kebijakan.
Tingkat Keparahan: Tinggi
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
procMount
string
Menentukan tipe Proc Mount. Nilai valid:
Default: Direktori /proc tidak dapat dipasang.
Unmasked: Direktori /proc dapat dipasang.
Untuk informasi lebih lanjut, lihat AllowedProcMountTypes.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPProcMount metadata: name: psp-proc-mount spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: procMount: Default # Default atau UnmaskedDiizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good1 namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: procMount: "Default"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad3 namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: procMount: "Unmasked" initContainers: - image: test name: test2ACKPSPReadOnlyRootFilesystem
Deskripsi Kebijakan: Pod di namespace tertentu harus berjalan dengan sistem file root hanya-baca.
Tingkat Keparahan: Sedang
Deskripsi Parameter: Tidak ada
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPReadOnlyRootFilesystem metadata: name: psp-readonlyrootfilesystem spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper"Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good1 namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: readOnlyRootFilesystem: trueTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad2 namespace: non-test-gatekeeper spec: containers: - image: test name: test securityContext: readOnlyRootFilesystem: false initContainers: - image: test name: test2ACKPSPSeccomp
Deskripsi Kebijakan: Pod di namespace tertentu harus dikonfigurasi dengan profil seccomp yang ditentukan.
Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedProfileTypes
array
Menentukan jenis profil seccomp yang diizinkan.
allowedProfiles
array
Menentukan profil seccomp yang diizinkan.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPSeccomp metadata: name: psp-seccomp spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: allowedProfileTypes: # - Unconfined - RuntimeDefault - Localhost allowedProfiles: - runtime/default - docker/default - localhost/profiles/audit.jsonDiizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: seccompProfile: type: Localhost localhostProfile: profiles/audit.json initContainers: - image: test name: test2 securityContext: seccompProfile: type: Localhost localhostProfile: profiles/audit.jsonTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test echo-k8s-webhook-enabled: 'true' name: bad namespace: test-gatekeeper spec: containers: - image: test name: testACKPSPSELinuxV2
Deskripsi Kebijakan: Pod di namespace tertentu tidak dapat dikonfigurasi dengan opsi SELinux yang tidak ditentukan oleh parameter allowedSELinuxOptions.
Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
allowedSELinuxOptios
object
Menentukan opsi SELinux yang dapat dikonfigurasikan untuk pod. Untuk informasi lebih lanjut, lihat SELinuxOptions v1 core.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPSELinuxV2 metadata: name: psp-selinux-v2 spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: allowedSELinuxOptions: - level: s0:c123,c456 role: object_r type: svirt_sandbox_file_t user: system_uDiizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: good namespace: test-gatekeeper spec: securityContext: seLinuxOptions: level: "s0:c123,c456" containers: - image: test name: testTidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad namespace: test-gatekeeper spec: containers: - image: test name: test securityContext: seLinuxOptions: level: "s0:c123,c455"ACKPSPVolumeTypes
Deskripsi Kebijakan: Hanya volume dari tipe tertentu yang dapat dipasang ke pod di namespace tertentu.
Tingkat Keparahan: Rendah
Berikut ini menjelaskan parameter.
Parameter
Tipe
Deskripsi
volumes
object
Menentukan tipe volume yang diizinkan untuk dipasang.
Contoh:
Batasan:
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: ACKPSPVolumeTypes metadata: name: psp-volume-types spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "test-gatekeeper" parameters: volumes: # - "*" # * dapat digunakan untuk mengizinkan semua tipe volume - configMap # - emptyDir - projected - secret - downwardAPI - persistentVolumeClaim # - hostPath # diperlukan untuk allowedHostPaths - flexVolume # diperlukan untuk allowedFlexVolumesDiizinkan:
apiVersion: v1 kind: Pod metadata: name: pv-oss namespace: test-gatekeeper spec: containers: - name: test image: test volumes: - name: test flexVolume: driver: "alicloud/oss"Tidak Diizinkan:
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: test name: bad-1 namespace: non-test-gatekeeper spec: containers: - image: test name: test volumes: - name: test-volume hostPath: path: /data