Skip to content

Commit 821202b

Browse files
authored
Merge pull request #64 from Peefy/add-more-aws-modules
feat: add aws releted kubernetes modules
2 parents dd03ca4 + 7173d29 commit 821202b

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Introduction
2+
3+
`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.
4+
5+
## Resource
6+
7+
The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/deamon-require-aws-node-irsa)

deamon-require-aws-node-irsa/kcl.mod

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "deamon-require-aws-node-irsa"
3+
version = "0.1.0"
4+
description = "`deamon-require-aws-node-irsa` is a kcl validation package"

deamon-require-aws-node-irsa/main.k

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Services of type LoadBalancer when deployed inside AWS have support for
2+
transport encryption if it is enabled via an annotation. This policy requires
3+
that Services of type LoadBalancer contain the annotation
4+
service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
5+
"""
6+
7+
# Define the validation function
8+
validate = lambda item {
9+
if item.kind == "DaemonSet" and item.metadata.name == "aws-node" and item.metadata.namespace == "kube-system":
10+
assert item.spec?.template?.spec?.serviceAccountName == "!aws-node", "Update the aws-node daemonset to use IRSA."
11+
item
12+
}
13+
14+
# Validate All resource
15+
items = [validate(i) for i in option("items")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Introduction
2+
3+
## Resource
4+
5+
The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/svc-require-encryption-aws-loadbalancers)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "svc-require-encryption-aws-loadbalancers"
3+
version = "0.1.0"
4+
description = "`svc-require-encryption-aws-loadbalancers` is a kcl validation package"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Services of type LoadBalancer when deployed inside AWS have support for
2+
transport encryption if it is enabled via an annotation. This policy requires
3+
that Services of type LoadBalancer contain the annotation
4+
service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
5+
"""
6+
7+
# Define the validation function
8+
validate = lambda item {
9+
if item.kind == "Service":
10+
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."
11+
item
12+
}
13+
14+
# Validate All resource
15+
items = [validate(i) for i in option("items")]

0 commit comments

Comments
 (0)