Skip to content

Commit

Permalink
chore(Clair-Action): Caching Updates (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVardevanyan committed Dec 23, 2024
1 parent c834ffe commit d3e7160
Show file tree
Hide file tree
Showing 20 changed files with 330 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .tekton/ansible-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ spec:
resources:
requests:
storage: "100Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion .tekton/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
resources:
requests:
storage: "100Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion .tekton/apache-php-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
resources:
requests:
storage: "100Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
4 changes: 2 additions & 2 deletions .tekton/overlay-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
resources:
requests:
storage: "100Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: kubernetes-json-schema
volumeClaimTemplate:
apiVersion: v1
Expand All @@ -115,7 +115,7 @@ spec:
resources:
requests:
storage: "250Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion .tekton/terraform-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
resources:
requests:
storage: "500Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion .tekton/terraform-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
resources:
requests:
storage: "500Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion .tekton/toolbox-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
resources:
requests:
storage: "100Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion .tekton/udi-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
resources:
requests:
storage: "100Mi"
storageClassName: rook-ceph-block
storageClassName: rook-ceph-block-ci
- name: git_auth_secret
secret:
secretName: "{{ git_auth_secret }}"
2 changes: 1 addition & 1 deletion containers/apache-php/containerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:sid-20241202-slim@sha256:2eac978892d960f967fdad9a5387eb0bf5addfa3fab7f6fa09a00e0adff7975d

ENV KICK="1"
ENV KICK="0"
LABEL quay.expires-after=${quay_expiration}

RUN apt-get update && apt-get install php php-mysql apache2 -y
Expand Down
2 changes: 1 addition & 1 deletion containers/toolbox/containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ENV \
PRETTIER_CLI_VERSION=3.3.3 \
HOME=/tmp \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin \
KICK="0"
KICK="1"

RUN rpm -Uvh https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm && \
rpm -ivh https://github.com/opentofu/opentofu/releases/download/v${OPENTOFU_VERSION}/tofu_${OPENTOFU_VERSION}_amd64.rpm && \
Expand Down
50 changes: 50 additions & 0 deletions kubernetes/ceph/base/file-ci/ceph-filesystem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: ceph.rook.io/v1
kind: CephFilesystem
metadata:
name: rook-ceph-fs-ci
namespace: rook-ceph
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
argocd.argoproj.io/sync-wave: "2"
spec:
metadataPool:
replicated:
size: 2
dataPools:
- name: replicated
replicated:
size: 2
preserveFilesystemOnDelete: true
metadataServer:
activeCount: 1
activeStandby: true
resources:
# limits:
# cpu: "3"
# memory: 8Gi
requests:
cpu: "10m"
memory: 128Mi
placement:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/infra
operator: Exists
tolerations:
- key: node-role.kubernetes.io/infra
operator: Exists
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: ceph-mds
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: ceph-mds
29 changes: 29 additions & 0 deletions kubernetes/ceph/base/file-ci/storage-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: rook-cephfs-ci
# Change "rook-ceph" provisioner prefix to match the operator namespace if needed
provisioner: rook-ceph.cephfs.csi.ceph.com
parameters:
# clusterID is the namespace where the rook cluster is running
# If you change this namespace, also change the namespace below where the secret namespaces are defined
clusterID: rook-ceph

# CephFS filesystem name into which the volume shall be created
fsName: rook-ceph-fs-ci

# Ceph pool into which the volume shall be created
# Required for provisionVolume: "true"
pool: rook-ceph-fs-ci-replicated

# The secrets contain Ceph admin credentials. These are generated automatically by the operator
# in the same namespace as the cluster.
csi.storage.k8s.io/provisioner-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/provisioner-secret-namespace: rook-ceph
csi.storage.k8s.io/controller-expand-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/controller-expand-secret-namespace: rook-ceph
csi.storage.k8s.io/node-stage-secret-name: rook-csi-cephfs-node
csi.storage.k8s.io/node-stage-secret-namespace: rook-ceph
allowVolumeExpansion: true
reclaimPolicy: Delete
2 changes: 2 additions & 0 deletions kubernetes/ceph/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ resources:
- ./file/storage-class.yaml
- ./file/ceph-filesystem.yaml
- ./object/storage-class.yaml
- ./file-ci/storage-class.yaml
- ./file-ci/ceph-filesystem.yaml
- ./object/ceph-object-store.yaml
- ./selinux.yaml
- ./rook-rules.yaml
Expand Down
34 changes: 34 additions & 0 deletions kubernetes/kubevirt/base/storage-profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,37 @@ spec:
- ReadWriteMany
volumeMode: Filesystem
cloneStrategy: csi-clone
---
apiVersion: cdi.kubevirt.io/v1beta1
kind: StorageProfile
metadata:
annotations:
argocd.argoproj.io/sync-wave: "3"
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
name: rook-ceph-block-ci
spec:
claimPropertySets:
- accessModes:
- ReadWriteMany
volumeMode: Block
- accessModes:
- ReadWriteOnce
volumeMode: Block
- accessModes:
- ReadWriteOnce
volumeMode: Filesystem
cloneStrategy: csi-clone
---
apiVersion: cdi.kubevirt.io/v1beta1
kind: StorageProfile
metadata:
annotations:
argocd.argoproj.io/sync-wave: "3"
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
name: rook-cephfs-ci
spec:
claimPropertySets:
- accessModes:
- ReadWriteMany
volumeMode: Filesystem
cloneStrategy: csi-clone
12 changes: 7 additions & 5 deletions tekton/base/clair-action/clair-action-task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ spec:
mkdir -p /vuln-store/db/
mkdir -p "${WORKSPACE_DATA_PATH}/clair-scan-report"
echo "Extracting Image"
oc image extract "${DB_IMAGE}" \
--path "/":"/vuln-store/db"
# echo "Extracting Image"
# oc image extract "${DB_IMAGE}" \
# --path "/":"/vuln-store/db"
echo "Running Clair Action"
clair-action report --image-ref=${IMAGE} \
Expand All @@ -94,8 +94,10 @@ spec:
emptyDir:
sizeLimit: 100Mi
- name: vuln-store
emptyDir:
sizeLimit: 15Gi
persistentVolumeClaim:
claimName: clair-action-vuln-store-cache
# emptyDir:
# sizeLimit: 15Gi
# ephemeral:
# volumeClaimTemplate:
# metadata:
Expand Down
70 changes: 70 additions & 0 deletions tekton/base/clair-action/cronjob-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: clair-action-cache-db
namespace: homelab
spec:
schedule: "55 */2 * * *"
concurrencyPolicy: Replace
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
suspend: false
startingDeadlineSeconds: 60
jobTemplate:
spec:
template:
spec:
serviceAccountName: pipeline
automountServiceAccountToken: false
securityContext:
seccompProfile:
type: RuntimeDefault
runAsNonRoot: true
containers:
- name: clair-action-cache
image: registry.arthurvardevanyan.com/homelab/toolbox:not_latest
command:
- /bin/bash
- -c
- |
#############################
### Clair Action DB Cache ###
#############################
export DB_IMAGE="registry.arthurvardevanyan.com/homelab/clair-action-db:latest"
mkdir -p /tmp/vuln-store/db
echo "Extracting Image"
oc image extract "${DB_IMAGE}" \
--path "/":"/tmp/vuln-store/db"
securityContext:
runAsNonRoot: true
privileged: false
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
resources:
requests:
memory: "128Mi"
cpu: "50m"
ephemeral-storage: 1Gi
limits:
memory: "256Mi"
cpu: "1000m"
ephemeral-storage: 1Gi
volumeMounts:
- name: tmp
mountPath: /tmp/
- name: vuln-store
mountPath: /tmp/vuln-store
restartPolicy: Never
volumes:
- name: tmp
emptyDir:
sizeLimit: 1Gi
- name: vuln-store
persistentVolumeClaim:
claimName: clair-action-vuln-store-cache
Loading

0 comments on commit d3e7160

Please sign in to comment.