Skip to content

Commit

Permalink
Add kubernetes-autoscaler-addon-resizer
Browse files Browse the repository at this point in the history
Signed-off-by: Furkan Türkal <[email protected]>
Co-authored-by: Batuhan <[email protected]>
Signed-off-by: Furkan Türkal <[email protected]>
  • Loading branch information
Dentrax and developer-guy committed Apr 13, 2024
1 parent 3aa86bd commit 7a70bcd
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 0 deletions.
37 changes: 37 additions & 0 deletions images/kubernetes-autoscaler-addon-resizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--monopod:start-->
# kubernetes-autoscaler-addon-resizer
| | |
| - | - |
| **OCI Reference** | `cgr.dev/chainguard/kubernetes-autoscaler-addon-resizer` |


* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/kubernetes-autoscaler-addon-resizer/overview/)
* [View Image Catalog](https://console.enforce.dev/images/catalog) for a full list of available tags.
* [Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*

---
<!--monopod:end-->

<!--overview:start-->
Addon-resizer is a container that vertically scales a Deployment based on the number of nodes in your cluster.
<!--overview:end-->

<!--getting:start-->
## Download this Image
The image is available on `cgr.dev`:

```
docker pull cgr.dev/chainguard/kubernetes-autoscaler-addon-resizer:latest
```
<!--getting:end-->

<!--body:start-->
## Usage

```bash
kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/master/addon-resizer/deploy/example.yaml
kubectl set image deployment/nanny-v1 pod-nanny=cgr.dev/chainguard/kubernetes-autoscaler-addon-resizer:latest
```

Find more on the [official documentation](https://github.com/kubernetes/autoscaler/blob/master/addon-resizer/README.md)!
<!--body:end-->
17 changes: 17 additions & 0 deletions images/kubernetes-autoscaler-addon-resizer/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "extra_packages" {
description = "Additional packages to install."
type = list(string)
default = ["addon-resizer", "addon-resizer-compat"]
}

module "accts" { source = "../../../tflib/accts" }

output "config" {
value = jsonencode({
contents = {
packages = var.extra_packages
}
accounts = module.accts.block
cmd = "/pod_nanny"
})
}
37 changes: 37 additions & 0 deletions images/kubernetes-autoscaler-addon-resizer/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
}
}

variable "target_repository" {
description = "The docker repo into which the image and attestations should be published."
}

module "config" { source = "./config" }

module "kubernetes-autoscaler-addon-resizer" {
source = "../../tflib/publisher"
name = basename(path.module)
target_repository = var.target_repository
config = module.config.config
build-dev = true
}

module "test" {
source = "./tests"
digest = module.kubernetes-autoscaler-addon-resizer.image_ref
}

resource "oci_tag" "latest" {
depends_on = [module.test]
digest_ref = module.kubernetes-autoscaler-addon-resizer.image_ref
tag = "latest"
}

resource "oci_tag" "latest-dev" {
depends_on = [module.test]
digest_ref = module.kubernetes-autoscaler-addon-resizer.dev_ref
tag = "latest-dev"
}

13 changes: 13 additions & 0 deletions images/kubernetes-autoscaler-addon-resizer/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: kubernetes-autoscaler-addon-resizer
image: cgr.dev/chainguard/kubernetes-autoscaler-addon-resizer
logo: https://storage.googleapis.com/chainguard-academy/logos/kubernetes-autoscaler-addon-resizer.svg
endoflife: ""
console_summary: ""
short_description: Addon-resizer is a container that vertically scales a Deployment based on the number of nodes in your cluster.
compatibility_notes: ""
readme_file: README.md
upstream_url: https://github.com/kubernetes/autoscaler/tree/master/addon-resizer
keywords:
- application
- kubernetes
- autoscaler
56 changes: 56 additions & 0 deletions images/kubernetes-autoscaler-addon-resizer/tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }

data "oci_exec_test" "help" {

Check failure on line 14 in images/kubernetes-autoscaler-addon-resizer/tests/main.tf

View workflow job for this annotation

GitHub Actions / build-the-world (0, kubernetes-autoscaler-addon-resizer)

Test failed

module.kubernetes-autoscaler-addon-resizer.module.test.data.oci_exec_test.help
digest = var.digest
script = "docker run --rm $IMAGE_NAME pod_nanny -h"
}

data "imagetest_inventory" "this" {}

resource "imagetest_harness_k3s" "this" {
name = "kubernetes-autoscaler-addon-resizer"
inventory = data.imagetest_inventory.this
}

resource "imagetest_feature" "basic" {
harness = imagetest_harness_k3s.this
name = "Basic"
description = "Basic functionality of the kubernetes-autoscaler-addon-resizer."

steps = [
{
name = "Deploy"
cmd = <<EOF
kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/master/addon-resizer/deploy/example.yaml
kubectl set image deployment/nanny-v1 pod-nanny="${data.oci_string.ref.registry_repo}:${data.oci_string.ref.pseudo_tag}"
EOF
},
{
name = "Ensure it comes up healthy"
cmd = <<EOF
kubectl rollout status deployment/nanny-v1 --timeout=120s
kubectl wait --for=condition=ready pod --selector k8s-app=nanny
EOF
retry = { attempts = 3, delay = "2s", factor = 2 }
},
{
name = "Check logs"
cmd = "kubectl logs deployment/nanny-v1 | grep -qi 'Watching namespace'"
}
]

labels = {
type = "k8s"
}
}
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,11 @@ module "kuberay-operator" {
target_repository = "${var.target_repository}/kuberay-operator"
}

module "kubernetes-autoscaler-addon-resizer" {
source = "./images/kubernetes-autoscaler-addon-resizer"
target_repository = "${var.target_repository}/kubernetes-autoscaler-addon-resizer"
}

module "kubernetes-csi-external-attacher" {
source = "./images/kubernetes-csi-external-attacher"
target_repository = "${var.target_repository}/kubernetes-csi-external-attacher"
Expand Down

0 comments on commit 7a70bcd

Please sign in to comment.