Skip to content

Commit

Permalink
Add workload resources, linting, validation, and update management (#5)
Browse files Browse the repository at this point in the history
* Add workload resources

* Add linting and validation

* Lint fix, rule config

* lint fix

* Add names to workflows

* remove other steps... why is this job not running?

* Remove paths

* narrow by branch not path

* Ignore missing schemas since I can't seem to find the kustomize schema

* move YAML patch into in-line

* Add checkov for IaC security scan

* fix checkov issues

* Remove security component, it's not going to work like we'd expect

* linting

* Checkin checkov config

* lint again
  • Loading branch information
highb committed May 1, 2023
1 parent 9244d68 commit 2f315e1
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 58 deletions.
9 changes: 9 additions & 0 deletions .checkov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
download-external-modules: false
evaluate-variables: true
framework:
- kustomize
- github_actions
quiet: true
skip-check:
- CKV2_K8S_6
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}
17 changes: 17 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Lint

# yamllint disable-line rule:truthy
on:
- pull_request

permissions:
contents: read

jobs:
yaml-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint YAML
uses: ibiqlik/action-yamllint@v3.1.1
34 changes: 34 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Validate

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
- "*"
push:
branches:
- main

permissions:
contents: read

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Login to Github Packages
run: echo "${{ github.token }}" | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin
- uses: actions/checkout@v3
- name: Run Kubeconform
uses: docker://ghcr.io/yannh/kubeconform:v0.6.1
with:
entrypoint: '/kubeconform'
args: "-ignore-missing-schemas -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' -summary components resources"

security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Checkov
uses: bridgecrewio/checkov-action@v12
11 changes: 11 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
extends: default

rules:
line-length:
max: 120
level: warning
truthy: disable
indentation:
indent-sequences: consistent
spaces: 2
13 changes: 0 additions & 13 deletions components/security/deployment.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions components/security/kustomization.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions components/security/securitycontext.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions components/security/statefulset.yaml

This file was deleted.

1 change: 1 addition & 0 deletions resources/external-secret-store/aws/service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
Expand Down
6 changes: 6 additions & 0 deletions resources/workload/cronjob/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# resources:
# - cronjob.yaml
56 changes: 56 additions & 0 deletions resources/workload/daemonset/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: UNDEFINED
namespace: UNDEFINED
labels:
k8s-app: UNDEFINED
spec:
selector:
matchLabels:
name: UNDEFINED
template:
metadata:
labels:
name: UNDEFINED
spec:
automountServiceAccountToken: false
securityContext:
seccompProfile:
type: RuntimeDefault
containers:
- name: UNDEFINED
image: UNDEFINED@sha256:abcd1234
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 5
resources:
limits:
cpu: 100m
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
terminationGracePeriodSeconds: 30
3 changes: 3 additions & 0 deletions resources/workload/daemonset/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
6 changes: 6 additions & 0 deletions resources/workload/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
3 changes: 3 additions & 0 deletions resources/workload/job/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
3 changes: 3 additions & 0 deletions resources/workload/replicaset/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
3 changes: 3 additions & 0 deletions resources/workload/statefulset/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

0 comments on commit 2f315e1

Please sign in to comment.