Compare commits

...

24 Commits
v0.4.0 ... main

Author SHA1 Message Date
dependabot[bot] a3f6886cb3
chore(deps): Bump actions/setup-python from 5.4.0 to 5.6.0 (#122)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.4.0 to 5.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5.4.0...v5.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 5.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 15:39:41 -04:00
dependabot[bot] 599aec9cbc
chore(deps): Bump tokio from 1.36.0 to 1.42.1 (#121)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.36.0 to 1.42.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.36.0...tokio-1.42.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.42.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 15:39:28 -04:00
dependabot[bot] 4b8134a5f8
chore(deps): Bump schemars from 0.8.21 to 0.8.22 (#118)
Bumps [schemars](https://github.com/GREsau/schemars) from 0.8.21 to 0.8.22.
- [Release notes](https://github.com/GREsau/schemars/releases)
- [Changelog](https://github.com/GREsau/schemars/blob/master/CHANGELOG.md)
- [Commits](https://github.com/GREsau/schemars/compare/v0.8.21...v0.8.22)

---
updated-dependencies:
- dependency-name: schemars
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 15:39:05 -04:00
dependabot[bot] 9c3208ee3a
chore(deps): Bump uuid from 1.5.0 to 1.12.1 (#114)
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.5.0 to 1.12.1.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.5.0...1.12.1)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 15:38:44 -04:00
Joonas Bergius c6d4e59028
chore: Add Security Policy with link to the main repository (#106)
Signed-off-by: Joonas Bergius <joonas@bergi.us>
2025-06-03 15:38:26 -04:00
dependabot[bot] cb051aac61
chore(deps): Bump serde_yaml from 0.9.25 to 0.9.29 (#83)
Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.9.25 to 0.9.29.
- [Release notes](https://github.com/dtolnay/serde-yaml/releases)
- [Commits](https://github.com/dtolnay/serde-yaml/compare/0.9.25...0.9.29)

---
updated-dependencies:
- dependency-name: serde_yaml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 15:37:27 -04:00
dependabot[bot] 52007e2927
chore(deps): Bump handlebars from 5.1.0 to 5.1.2 (#77)
Bumps [handlebars](https://github.com/sunng87/handlebars-rust) from 5.1.0 to 5.1.2.
- [Release notes](https://github.com/sunng87/handlebars-rust/releases)
- [Changelog](https://github.com/sunng87/handlebars-rust/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sunng87/handlebars-rust/compare/v5.1.0...v5.1.2)

---
updated-dependencies:
- dependency-name: handlebars
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 15:37:10 -04:00
Nicolas Lamirault bc2d7bbea2
feat(helm): Kubernetes labels (#119)
Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
2025-03-03 09:48:22 -05:00
Eric Gregory d4758e98f1 fix(examples): change http provider address for hello world app
Signed-off-by: Eric Gregory <egregory04@gmail.com>
2025-02-14 09:15:40 -05:00
dependabot[bot] 9cf6542828
chore(deps): Bump helm/kind-action from 1.10.0 to 1.12.0 (#109)
Bumps [helm/kind-action](https://github.com/helm/kind-action) from 1.10.0 to 1.12.0.
- [Release notes](https://github.com/helm/kind-action/releases)
- [Commits](https://github.com/helm/kind-action/compare/v1.10.0...v1.12.0)

---
updated-dependencies:
- dependency-name: helm/kind-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-14 08:14:56 -06:00
dependabot[bot] 8d495ec202
chore(deps): Bump helm/chart-testing-action from 2.6.1 to 2.7.0 (#115)
Bumps [helm/chart-testing-action](https://github.com/helm/chart-testing-action) from 2.6.1 to 2.7.0.
- [Release notes](https://github.com/helm/chart-testing-action/releases)
- [Commits](https://github.com/helm/chart-testing-action/compare/v2.6.1...v2.7.0)

---
updated-dependencies:
- dependency-name: helm/chart-testing-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-14 08:14:24 -06:00
dependabot[bot] b7e4bf3761
chore(deps): Bump actions/setup-python from 5.3.0 to 5.4.0 (#116)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.3.0 to 5.4.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5.3.0...v5.4.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-14 08:13:19 -06:00
Taylor Thomas f9daa35480
chore(yaml): Update version in the kustomize yaml (#112)
We were pinned to an old version so when I deployed as directed in the
README it deployed an old version without the new features I needed

Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
2025-01-10 16:00:50 -06:00
Joonas Bergius d74ad8bff7
feat: Support customizing the container templates for wasmcloud and nats (#110)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2025-01-09 13:01:37 -06:00
Joonas Bergius 4ccfb20b30
chore(wasmcloud-operator-types): Add cargo machete ignore for serde_json with NOTE (#104)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2024-11-18 12:38:28 -06:00
dependabot[bot] 59552d2277
chore(deps): Bump actions/setup-python from 5.1.1 to 5.3.0 (#102)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.1 to 5.3.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5.1.1...v5.3.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-25 09:36:21 -05:00
Joonas Bergius 1b129d69c9
chore: List maintainer affiliations (#99)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2024-10-12 19:02:47 -05:00
Joonas Bergius fff57db4fb chore: Add CODEOWNERS file
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2024-10-12 16:05:58 -04:00
Brooks Townsend 1c85b3937c chore: add MAINTAINERS.md
Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>
2024-10-12 14:45:36 -04:00
Joonas Bergius 309b492dcd
feat: Add rudimentary version flag (#95)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2024-09-23 19:29:15 -05:00
Joonas Bergius 0aaa277422
feat: Add wolfi-based image (#94)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2024-09-23 14:40:13 -05:00
Lucas Fontes 6f63289a11
feat: Configure max component memory (#91)
* feat: Configure max component memory

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>

* chore: Bumping versions

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>

---------

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
2024-08-20 14:33:52 -05:00
Bailey Hayes 788cbc089d
fix(examples): add daemonscaler to httpserver (#87)
This will allow the k8s operator to automatically
create services. This shouldn't be required in
the future when the operator supports the spreadscaler
for httpserver providers as well.

Signed-off-by: Bailey Hayes <behayes2@gmail.com>
2024-08-12 12:31:42 -05:00
Joonas Bergius 4ab407dc15
chore: Bump wasmcloud-operator chart appVersion (#85)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
2024-08-01 12:52:00 -05:00
18 changed files with 226 additions and 87 deletions

2
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,2 @@
# wasmCloud operator maintainers
* @wasmCloud/operator-maintainers

View File

@ -86,6 +86,15 @@ jobs:
type=sha,prefix=
type=semver,pattern={{version}}
- name: Extract metadata (tags, labels) for Docker
id: meta_wolfi
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=,suffix=-wolfi
type=semver,pattern={{version}},suffix=-wolfi
- name: Load artifacts
uses: actions/download-artifact@v4
with:
@ -106,3 +115,14 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: "BIN_PATH=artifacts/wasmcloud-operator"
- name: Build and push Docker image (wolfi)
uses: docker/build-push-action@v6
with:
push: true
context: .
file: './Dockerfile.wolfi'
tags: ${{ steps.meta_wolfi.outputs.tags }}
labels: ${{ steps.meta_wolfi.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: "BIN_PATH=artifacts/wasmcloud-operator"

View File

@ -32,12 +32,12 @@ jobs:
# Used by helm chart-testing below
- name: Set up Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.6.0
with:
python-version: '3.12.2'
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.1
uses: helm/chart-testing-action@v2.7.0
with:
version: v3.10.1
yamllint_version: 1.35.1
@ -48,7 +48,7 @@ jobs:
ct lint --config charts/wasmcloud-operator/ct.yaml
- name: Create kind cluster
uses: helm/kind-action@v1.10.0
uses: helm/kind-action@v1.12.0
with:
version: "v0.22.0"

66
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -974,9 +974,9 @@ dependencies = [
[[package]]
name = "handlebars"
version = "5.1.0"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4"
checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b"
dependencies = [
"log",
"pest",
@ -1037,9 +1037,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.3"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hex"
@ -1580,13 +1580,14 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.11"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [
"hermit-abi",
"libc",
"wasi",
"windows-sys 0.48.0",
"windows-sys 0.52.0",
]
[[package]]
@ -1759,16 +1760,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "object"
version = "0.32.1"
@ -2468,9 +2459,9 @@ dependencies = [
[[package]]
name = "schemars"
version = "0.8.15"
version = "0.8.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c"
checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615"
dependencies = [
"dyn-clone",
"schemars_derive",
@ -2480,14 +2471,14 @@ dependencies = [
[[package]]
name = "schemars_derive"
version = "0.8.15"
version = "0.8.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c"
checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d"
dependencies = [
"proc-macro2",
"quote",
"serde_derive_internals",
"syn 1.0.109",
"syn 2.0.38",
]
[[package]]
@ -2589,13 +2580,13 @@ dependencies = [
[[package]]
name = "serde_derive_internals"
version = "0.26.0"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c"
checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.38",
]
[[package]]
@ -2653,9 +2644,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.9.25"
version = "0.9.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574"
checksum = "a15e0ef66bf939a7c890a0bf6d5a733c70202225f9888a89ed5c62298b019129"
dependencies = [
"indexmap 2.0.2",
"itoa",
@ -2948,21 +2939,20 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.36.0"
version = "1.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
checksum = "2209a14885b74764cce87ffa777ffa1b8ce81a3f3166c6f886b83337fe7e077f"
dependencies = [
"backtrace",
"bytes",
"libc",
"mio",
"num_cpus",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2 0.5.6",
"tokio-macros",
"windows-sys 0.48.0",
"windows-sys 0.52.0",
]
[[package]]
@ -2977,9 +2967,9 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "2.2.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
@ -3391,9 +3381,9 @@ dependencies = [
[[package]]
name = "uuid"
version = "1.5.0"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc"
checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b"
dependencies = [
"getrandom",
"serde",
@ -3717,7 +3707,7 @@ dependencies = [
[[package]]
name = "wasmcloud-operator"
version = "0.4.0"
version = "0.5.0"
dependencies = [
"anyhow",
"async-nats",
@ -3757,7 +3747,7 @@ dependencies = [
[[package]]
name = "wasmcloud-operator-types"
version = "0.1.7"
version = "0.1.9"
dependencies = [
"k8s-openapi",
"kube",

View File

@ -1,6 +1,6 @@
[package]
name = "wasmcloud-operator"
version = "0.4.0"
version = "0.5.0"
edition = "2021"
[[bin]]
@ -77,7 +77,7 @@ opentelemetry_sdk = { version = "0.21", features = [
"metrics",
"trace",
"rt-tokio",
]}
] }
opentelemetry-otlp = { version = "0.14", features = ["tokio"] }
rcgen = "0.11"
schemars = "0.8"

7
Dockerfile.wolfi Normal file
View File

@ -0,0 +1,7 @@
# syntax=docker/dockerfile:1
FROM chainguard/wolfi-base:latest
ARG BIN_PATH
ARG TARGETARCH
COPY ${BIN_PATH}-${TARGETARCH} /usr/local/bin/wasmcloud-operator
ENTRYPOINT ["/usr/local/bin/wasmcloud-operator"]

22
MAINTAINERS.md Normal file
View File

@ -0,0 +1,22 @@
# MAINTAINERS
The following individuals are responsible for reviewing code, managing issues, and ensuring the overall quality of `wasmcloud-operator`.
## @wasmCloud/operator-maintainers
Name: Joonas Bergius
GitHub: @joonas
Organization: Cosmonic
Name: Dan Norris
GitHub: @protochron
Organization: Cosmonic
Name: Taylor Thomas
GitHub: @thomastaylor312
Organization: Cosmonic
Name: Lucas Fontes
GitHub: @lxfontes
Organization: Cosmonic

3
SECURITY.md Normal file
View File

@ -0,0 +1,3 @@
# Reporting a security issue
Please refer to the [wasmCloud Security Process and Policy](https://github.com/wasmCloud/wasmCloud/blob/main/SECURITY.md) for details on how to report security issues and vulnerabilities.

View File

@ -7,10 +7,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.4
version: 0.1.6
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.3.2"
appVersion: "0.4.0"

View File

@ -43,10 +43,15 @@ Common labels
{{- define "wasmcloud-operator.labels" -}}
helm.sh/chart: {{ include "wasmcloud-operator.chart" . }}
{{ include "wasmcloud-operator.selectorLabels" . }}
app.kubernetes.io/component: operator
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: wasmcloud-operator
{{- with .Values.additionalLabels }}
{{ . | toYaml }}
{{- end }}
{{- end }}
{{/*

View File

@ -12,6 +12,9 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
additionalLabels: {}
# app: wasmcloud-operator
serviceAccount:
# Specifies whether a service account should be created
create: true

View File

@ -1,11 +1,16 @@
[package]
name = "wasmcloud-operator-types"
version = "0.1.7"
version = "0.1.9"
edition = "2021"
[package.metadata.cargo-machete]
# NOTE: This exists because kube-derive needs it, and for reasons I don't
# fully understand, it's not coming through kube-derive's own depedendencies.
ignored = ["serde_json"]
[dependencies]
k8s-openapi = {workspace = true}
kube = {workspace = true, features = ["derive"]}
schemars = {workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
k8s-openapi = { workspace = true }
kube = { workspace = true, features = ["derive"] }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }

View File

@ -1,4 +1,4 @@
use k8s_openapi::api::core::v1::{PodSpec, ResourceRequirements, Volume};
use k8s_openapi::api::core::v1::{Container, PodSpec, ResourceRequirements, Volume};
use kube::CustomResource;
use schemars::{gen::SchemaGenerator, schema::Schema, JsonSchema};
use serde::{Deserialize, Serialize};
@ -82,6 +82,8 @@ pub struct WasmCloudHostConfigSpec {
pub certificates: Option<WasmCloudHostCertificates>,
/// wasmCloud secrets topic prefix, must not be empty if set.
pub secrets_topic_prefix: Option<String>,
/// Maximum memory in bytes that components can use.
pub max_linear_memory_bytes: Option<u32>,
}
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
@ -102,9 +104,23 @@ pub struct KubernetesSchedulingOptions {
/// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for valid
/// values to use here.
pub resources: Option<WasmCloudHostConfigResources>,
#[schemars(schema_with = "pod_schema")]
/// Any other pod template spec options to set for the underlying wasmCloud host pods.
#[schemars(schema_with = "pod_schema")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pod_template_additions: Option<PodSpec>,
/// Allow for customization of either the wasmcloud or nats leaf container inside of the wasmCloud host pod.
pub container_template_additions: Option<ContainerTemplateAdditions>,
}
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ContainerTemplateAdditions {
#[schemars(schema_with = "container_schema")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub nats: Option<Container>,
#[schemars(schema_with = "container_schema")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub wasmcloud: Option<Container>,
}
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
@ -163,6 +179,24 @@ fn pod_schema(_gen: &mut SchemaGenerator) -> Schema {
val.schema.into()
}
/// This is a workaround for the fact that we can't override the Container schema to make name
/// an optional field. It generates the OpenAPI schema for the Container type the same way that
/// kube.rs does while dropping any required fields.
fn container_schema(_gen: &mut SchemaGenerator) -> Schema {
let gen = schemars::gen::SchemaSettings::openapi3()
.with(|s| {
s.inline_subschemas = true;
s.meta_schema = None;
})
.with_visitor(kube::core::schema::StructuralSchemaRewriter)
.into_generator();
let mut val = gen.into_root_schema_for::<Container>();
// Drop `name` as a required field as it will be filled in from container
// definition coming the controller that this configuration gets merged into.
val.schema.object.as_mut().unwrap().required = BTreeSet::new();
val.schema.into()
}
fn default_host_replicas() -> u32 {
1
}

View File

@ -15,7 +15,7 @@ spec:
spec:
serviceAccountName: wasmcloud-operator
containers:
- image: ghcr.io/wasmcloud/wasmcloud-operator:0.3.2
- image: ghcr.io/wasmcloud/wasmcloud-operator:0.5.0
imagePullPolicy: Always
name: wasmcloud-operator
ports:

View File

@ -71,6 +71,8 @@ spec:
# Optional: Subject prefix that will be used by the host to query for wasmCloud Secrets.
# See https://wasmcloud.com/docs/concepts/secrets for more context
secretsTopicPrefix: "wasmcloud.secrets"
# Optional: The maximum amount of memory bytes that a component can allocate.
maxLinearMemoryBytes: 20000000
# Optional: Additional options to control how the underlying wasmCloud hosts are scheduled in Kubernetes.
# This includes setting resource requirements for the nats and wasmCloud host
# containers along with any additional pot template settings.

View File

@ -19,9 +19,9 @@ spec:
image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0
traits:
# Govern the spread/scheduling of the component
- type: spreadscaler
- type: daemonscaler
properties:
replicas: 1
replicas: 100
# Add a capability provider that enables HTTP access
- name: httpserver
@ -30,9 +30,11 @@ spec:
image: ghcr.io/wasmcloud/http-server:0.21.0
traits:
# Establish a unidirectional link from this http server provider (the "source")
# to the `http-component` component (the "target") so the component can handle incoming HTTP requests,
# to the `http-component` component (the "target") so the component can handle incoming HTTP requests.
#
# The source (this provider) is configured such that the HTTP server listens on 127.0.0.1:8080
# The source (this provider) is configured such that the HTTP server listens on 0.0.0.0:8000.
# When running the application on Kubernetes with the wasmCloud operator, you can change the
# port but the address must be 0.0.0.0.
- type: link
properties:
target: http-component
@ -42,4 +44,10 @@ spec:
source_config:
- name: default-http
properties:
address: 127.0.0.1:8080
address: 0.0.0.0:8000
# When running the application on Kubernetes with the wasmCloud operator,
# the operator automatically creates a Kubernetes service for applications that use
# the httpserver provider with a daemonscaler.
- type: daemonscaler
properties:
replicas: 1

View File

@ -13,6 +13,7 @@ use k8s_openapi::api::core::v1::{
};
use k8s_openapi::api::rbac::v1::{PolicyRule, Role, RoleBinding, RoleRef, Subject};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector;
use k8s_openapi::DeepMerge;
use kube::{
api::{Api, ObjectMeta, Patch, PatchParams},
client::Client as KubeClient,
@ -381,6 +382,14 @@ async fn pod_template(config: &WasmCloudHostConfig, ctx: Arc<Context>) -> Result
})
}
if let Some(max_linear_memory_bytes) = &config.spec.max_linear_memory_bytes {
wasmcloud_env.push(EnvVar {
name: "WASMCLOUD_MAX_LINEAR_MEMORY".to_string(),
value: Some(max_linear_memory_bytes.to_string()),
..Default::default()
})
}
let mut wasmcloud_args = configure_observability(&config.spec);
let mut nats_resources: Option<k8s_openapi::api::core::v1::ResourceRequirements> = None;
@ -538,7 +547,7 @@ async fn pod_template(config: &WasmCloudHostConfig, ctx: Arc<Context>) -> Result
});
}
let containers = vec![
let mut containers = vec![
Container {
name: "nats-leaf".to_string(),
image: Some(leaf_image),
@ -578,6 +587,22 @@ async fn pod_template(config: &WasmCloudHostConfig, ctx: Arc<Context>) -> Result
},
];
if let Some(cta) = &config
.spec
.scheduling_options
.as_ref()
.and_then(|so| so.container_template_additions.clone())
{
if let Some(mut nats_container) = cta.nats.clone() {
nats_container.merge_from(containers[0].clone());
containers[0] = nats_container;
}
if let Some(mut wasmcloud_container) = cta.wasmcloud.clone() {
wasmcloud_container.merge_from(containers[1].clone());
containers[1] = wasmcloud_container;
}
}
let service_account = config.name_any();
let mut template = PodTemplateSpec {
metadata: Some(ObjectMeta {
@ -822,35 +847,37 @@ async fn configure_hosts(config: &WasmCloudHostConfig, ctx: Arc<Context>) -> Res
];
}
if let Some(scheduling_options) = &config.spec.scheduling_options {
if scheduling_options.daemonset {
let mut spec = daemonset_spec(config, ctx.clone()).await?;
spec.template.spec.as_mut().unwrap().containers[1]
.env
.as_mut()
.unwrap()
.append(&mut env_vars);
let ds = DaemonSet {
metadata: ObjectMeta {
name: Some(config.name_any()),
namespace: Some(config.namespace().unwrap()),
owner_references: Some(vec![config.controller_owner_ref(&()).unwrap()]),
labels: Some(common_labels()),
..Default::default()
},
spec: Some(spec),
if config
.spec
.scheduling_options
.as_ref()
.is_some_and(|so| so.daemonset)
{
let mut spec = daemonset_spec(config, ctx.clone()).await?;
spec.template.spec.as_mut().unwrap().containers[1]
.env
.as_mut()
.unwrap()
.append(&mut env_vars);
let ds = DaemonSet {
metadata: ObjectMeta {
name: Some(config.name_any()),
namespace: Some(config.namespace().unwrap()),
owner_references: Some(vec![config.controller_owner_ref(&()).unwrap()]),
labels: Some(common_labels()),
..Default::default()
};
},
spec: Some(spec),
..Default::default()
};
let api =
Api::<DaemonSet>::namespaced(ctx.client.clone(), &config.namespace().unwrap());
api.patch(
&config.name_any(),
&PatchParams::apply(CLUSTER_CONFIG_FINALIZER),
&Patch::Apply(ds),
)
.await?;
}
let api = Api::<DaemonSet>::namespaced(ctx.client.clone(), &config.namespace().unwrap());
api.patch(
&config.name_any(),
&PatchParams::apply(CLUSTER_CONFIG_FINALIZER),
&Patch::Apply(ds),
)
.await?;
} else {
let mut spec = deployment_spec(config, ctx.clone()).await?;
spec.template.spec.as_mut().unwrap().containers[1]

View File

@ -28,6 +28,13 @@ use wasmcloud_operator_types::v1alpha1::WasmCloudHostConfig;
#[tokio::main]
async fn main() -> Result<()> {
let args = std::env::args().collect::<Vec<_>>();
if args.iter().any(|arg| arg == "-V" || arg == "--version") {
let version = version();
println!("{} {version}", env!("CARGO_BIN_NAME"));
std::process::exit(0);
}
let tracing_enabled = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT").is_ok();
configure_tracing(tracing_enabled).map_err(|e| {
error!("Failed to configure tracing: {}", e);
@ -192,3 +199,7 @@ async fn install_crd(client: &Client) -> anyhow::Result<()> {
Ok(())
}
fn version() -> &'static str {
option_env!("CARGO_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION"))
}