Skip to content

Commit

Permalink
Allow endpoint config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Brice committed Jul 27, 2024
1 parent bc3a25a commit 56eb6f4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
41 changes: 21 additions & 20 deletions modules/oracledb-exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,31 @@ timoni -n default delete oracledb-exporter

### Oracle DB Exporter values

| Key | Type | Default | Description |
|--------|-----------------------|---------|----------------------------------------------------------------------|
| `env:` | `[...corev1.#EnvVar]` | `[]` | Environment variables passed to the container. `DATA_SOURCE_NAME` required. |
| Key | Type | Default | Description |
| ------------ | ------------------------------------ | ------- | --------------------------------------------------------------------------- |
| `env:` | `[...corev1.#EnvVar]` | `[]` | Environment variables passed to the container. `DATA_SOURCE_NAME` required. |
| `endpoints:` | `smv1.#ServiceMonitorSpec.endpoints` | `[...]` | Prometheus Service Monitor endpoints. |

### General values

| Key | Type | Default | Description |
|------------------------------|-----------------------------------------|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `image: tag:` | `string` | `<latest version>` | Container image tag |
| `image: digest:` | `string` | `<latest digest>` | Container image digest, takes precedence over `tag` when specified |
| Key | Type | Default | Description |
| ---------------------------- | --------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `image: tag:` | `string` | `<latest version>` | Container image tag |
| `image: digest:` | `string` | `<latest digest>` | Container image digest, takes precedence over `tag` when specified |
| `image: repository:` | `string` | `ghcr.io/iamseth/oracledb_exporter` | Container image repository |
| `image: pullPolicy:` | `string` | `IfNotPresent` | [Kubernetes image pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) |
| `metadata: labels:` | `{[ string]: string}` | `{}` | Common labels for all resources |
| `metadata: annotations:` | `{[ string]: string}` | `{}` | Common annotations for all resources |
| `podAnnotations:` | `{[ string]: string}` | `{}` | Annotations applied to pods |
| `imagePullSecrets:` | `[...timoniv1.ObjectReference]` | `[]` | [Kubernetes image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) |
| `tolerations:` | `[ ...corev1.#Toleration]` | `[]` | [Kubernetes toleration](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
| `affinity:` | `corev1.#Affinity` | `{}` | [Kubernetes affinity and anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) |
| `resources:` | `timoniv1.#ResourceRequirements` | `{}` | [Kubernetes resource requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) |
| `topologySpreadConstraints:` | `[...corev1.#TopologySpreadConstraint]` | `[]` | [Kubernetes pod topology spread constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints) |
| `podSecurityContext:` | `corev1.#PodSecurityContext` | `{}` | [Kubernetes pod security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context) |
| `securityContext:` | `corev1.#SecurityContext` | `{}` | [Kubernetes container security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context) |
| `service: annotations:` | `{[ string]: string}` | `{}` | Annotations applied to the Kubernetes Service |
| `service: port:` | `int` | `9161` | Kubernetes Service HTTP port |
| `image: pullPolicy:` | `string` | `IfNotPresent` | [Kubernetes image pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) |
| `metadata: labels:` | `{[ string]: string}` | `{}` | Common labels for all resources |
| `metadata: annotations:` | `{[ string]: string}` | `{}` | Common annotations for all resources |
| `podAnnotations:` | `{[ string]: string}` | `{}` | Annotations applied to pods |
| `imagePullSecrets:` | `[...timoniv1.ObjectReference]` | `[]` | [Kubernetes image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) |
| `tolerations:` | `[ ...corev1.#Toleration]` | `[]` | [Kubernetes toleration](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
| `affinity:` | `corev1.#Affinity` | `{}` | [Kubernetes affinity and anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) |
| `resources:` | `timoniv1.#ResourceRequirements` | `{}` | [Kubernetes resource requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) |
| `topologySpreadConstraints:` | `[...corev1.#TopologySpreadConstraint]` | `[]` | [Kubernetes pod topology spread constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints) |
| `podSecurityContext:` | `corev1.#PodSecurityContext` | `{}` | [Kubernetes pod security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context) |
| `securityContext:` | `corev1.#SecurityContext` | `{}` | [Kubernetes container security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context) |
| `service: annotations:` | `{[ string]: string}` | `{}` | Annotations applied to the Kubernetes Service |
| `service: port:` | `int` | `9161` | Kubernetes Service HTTP port |

#### Recommended values

Expand Down
9 changes: 6 additions & 3 deletions modules/oracledb-exporter/templates/config.cue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package templates
import (
corev1 "k8s.io/api/core/v1"
timoniv1 "timoni.sh/core/v1alpha1"
smv1 "monitoring.coreos.com/servicemonitor/v1"
)

// Config defines the schema and defaults for the Instance values.
Expand Down Expand Up @@ -80,9 +81,8 @@ import (
env!: [...corev1.#EnvVar] & [
{
// An Oracle Database connection string for the Go lang driver. https://github.com/iamseth/oracledb_exporter?tab=readme-ov-file#running
name: "DATA_SOURCE_NAME"
value: string
},
name: "DATA_SOURCE_NAME"
} & corev1.#EnvVar
]

// Pod optional settings.
Expand All @@ -92,6 +92,9 @@ import (
tolerations?: [...corev1.#Toleration]
affinity?: corev1.#Affinity
topologySpreadConstraints?: [...corev1.#TopologySpreadConstraint]

// Service Monitor optional settings.
endpoints?: smv1.#ServiceMonitorSpec.endpoints
}

// Instance takes the config values and outputs the Kubernetes objects.
Expand Down
20 changes: 13 additions & 7 deletions modules/oracledb-exporter/templates/servicemonitor.cue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ import (
spec: {
selector: matchLabels: "app.kubernetes.io/name": #config.metadata.name
namespaceSelector: matchNames: [#config.metadata.namespace]
endpoints: [
{
port: "http"
path: "/metrics"
interval: "1s"
},
]
if #config.endpoints == _|_ {
endpoints: [
{
port: "http"
path: "/metrics"
interval: "1m"
scrapeTimeout: "30s"
},
]
}
if #config.endpoints != _|_ {
endpoints: #config.endpoints
}
}
}

0 comments on commit 56eb6f4

Please sign in to comment.