Skip to content

Commit

Permalink
add k8ssandra-system-logger
Browse files Browse the repository at this point in the history
Signed-off-by: Furkan Türkal <[email protected]>
  • Loading branch information
Dentrax committed Feb 28, 2024
1 parent 1f6e3e5 commit d2bca90
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 0 deletions.
28 changes: 28 additions & 0 deletions images/k8ssandra-system-logger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--monopod:start-->
# k8ssandra-system-logger
| | |
| - | - |
| **OCI Reference** | `cgr.dev/chainguard/k8ssandra-system-logger` |


* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/k8ssandra-system-logger/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-->
Sidecar for DataStax Kubernetes Operator for Apache Cassandra
<!--overview:end-->

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

```
docker pull cgr.dev/chainguard/k8ssandra-system-logger:latest
```
<!--getting:end-->

<!--body:start--><!--body:end-->
29 changes: 29 additions & 0 deletions images/k8ssandra-system-logger/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "name" {
description = "Package name (e.g. cainjector, acmeresolver, controller, webhook)"
}

variable "extra_packages" {
description = "Additional packages to install."
type = list(string)
default = []
}

module "accts" {
source = "../../../tflib/accts"
run-as = 65532
uid = 65532
gid = 65532
name = var.name
}

output "config" {
value = jsonencode({
contents = {
packages = ["cass-operator-config", "vector", "libstdc++"]
}
accounts = module.accts.block
entrypoint = {
command = "/usr/bin/vector"
}
})
}
36 changes: 36 additions & 0 deletions images/k8ssandra-system-logger/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 "latest-config" { source = "./config" }

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

module "test-latest" {
source = "./tests"
digest = module.latest.image_ref
}

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

resource "oci_tag" "latest-dev" {
depends_on = [module.test-latest]
digest_ref = module.latest.dev_ref
tag = "latest-dev"
}
9 changes: 9 additions & 0 deletions images/k8ssandra-system-logger/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: k8ssandra-system-logger
image: cgr.dev/chainguard/k8ssandra-system-logger
logo: https://storage.googleapis.com/chainguard-academy/logos/k8ssandra-system-logger.svg
endoflife: ""
console_summary: ""
short_description: Sidecar for DataStax Kubernetes Operator for Apache Cassandra
compatibility_notes: ""
readme_file: README.md
upstream_url: https://github.com/k8ssandra/cass-operator/blob/master/logger.Dockerfile
26 changes: 26 additions & 0 deletions images/k8ssandra-system-logger/tests/01-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o errtrace -o pipefail -x

NAME="k8ssandra-system-logger"

docker run --rm -d --name "$NAME" ${IMAGE_NAME}

sleep 10

logs=$(docker logs "$NAME" 2>&1)

docker kill --signal=INT "$NAME"
docker wait "$NAME"

asserts=("Vector has started." "Healthcheck passed.")

# assert that all the expected logs are present
for assert in "${asserts[@]}"; do
if ! echo "$logs" | grep -q "$assert"; then
echo "Assertion failed: $assert"
exit 1
fi
done

echo "All assertions passed."
22 changes: 22 additions & 0 deletions images/k8ssandra-system-logger/tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
helm = { source = "hashicorp/helm" }
}
}

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

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

data "oci_exec_test" "help" {
digest = var.digest
script = "docker run --rm $IMAGE_NAME --help"
}

data "oci_exec_test" "test" {
digest = var.digest
script = "${path.module}/01-test.sh"
}
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@ module "k8ssandra-operator" {
target_repository = "${var.target_repository}/k8ssandra-operator"
}

module "k8ssandra-system-logger" {
source = "./images/k8ssandra-system-logger"
target_repository = "${var.target_repository}/k8ssandra-system-logger"
}

module "kafka" {
source = "./images/kafka"
target_repository = "${var.target_repository}/kafka"
Expand Down

0 comments on commit d2bca90

Please sign in to comment.