Skip to content

Commit

Permalink
feat: add aws releated kubernetes modules
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Nov 9, 2023
1 parent dd03ca4 commit 7173d29
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deamon-require-aws-node-irsa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`deamon-require-aws-node-irsa` is a KCL validation package to validate services of type LoadBalancer when deployed inside AWS have support for transport encryption if it is enabled via an annotation. This policy requires that Services of type LoadBalancer contain the annotation `service.beta.kubernetes.io/aws-load-balancer-ssl-cert` with some value.

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/deamon-require-aws-node-irsa)
4 changes: 4 additions & 0 deletions deamon-require-aws-node-irsa/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "deamon-require-aws-node-irsa"
version = "0.1.0"
description = "`deamon-require-aws-node-irsa` is a kcl validation package"
15 changes: 15 additions & 0 deletions deamon-require-aws-node-irsa/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Services of type LoadBalancer when deployed inside AWS have support for
transport encryption if it is enabled via an annotation. This policy requires
that Services of type LoadBalancer contain the annotation
service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
"""

# Define the validation function
validate = lambda item {
if item.kind == "DaemonSet" and item.metadata.name == "aws-node" and item.metadata.namespace == "kube-system":
assert item.spec?.template?.spec?.serviceAccountName == "!aws-node", "Update the aws-node daemonset to use IRSA."
item
}

# Validate All resource
items = [validate(i) for i in option("items")]
5 changes: 5 additions & 0 deletions svc-require-encryption-aws-loadbalancers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Introduction

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/svc-require-encryption-aws-loadbalancers)
4 changes: 4 additions & 0 deletions svc-require-encryption-aws-loadbalancers/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "svc-require-encryption-aws-loadbalancers"
version = "0.1.0"
description = "`svc-require-encryption-aws-loadbalancers` is a kcl validation package"
15 changes: 15 additions & 0 deletions svc-require-encryption-aws-loadbalancers/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Services of type LoadBalancer when deployed inside AWS have support for
transport encryption if it is enabled via an annotation. This policy requires
that Services of type LoadBalancer contain the annotation
service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
"""

# Define the validation function
validate = lambda item {
if item.kind == "Service":
assert item.metadata?.annotation?["service.beta.kubernetes.io/aws-load-balancer-ssl-cert"] if item?.spec?.type == "LoadBalancer", "Service of type LoadBalancer must carry the annotation service.beta.kubernetes.io/aws-load-balancer-ssl-cert."
item
}

# Validate All resource
items = [validate(i) for i in option("items")]

0 comments on commit 7173d29

Please sign in to comment.