Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: operator #53

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
8000
],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install mkdocs mkdocs-material pymdown-extensions mkdocs-video",
"postCreateCommand": "pip install mkdocs mkdocs-material pymdown-extensions mkdocs-video mkdocs-macros-plugin",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"updateRemoteUserUID": true,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material pymdown-extensions mkdocs-video
- run: pip install mkdocs-material pymdown-extensions mkdocs-video mkdocs-macros-plugin
- run: mkdocs gh-deploy --force
24 changes: 24 additions & 0 deletions .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Unit tests
on: pull_request_target
permissions:
pull-requests: write
issues: write
repository-projects: write
contents: write
jobs:
testsunit:
needs: [pre-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CHANGELOG_PAT }}
ref: ${{ github.ref }}
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: go mod download
- name: Run Go unit tests
env:
run: |
go test $(go list ./... | grep -v /internal/registry)
5 changes: 2 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
paths:
- '**.go'
- '.golangci.yml'

# Testing only needs permissions to read the repository contents.
permissions:
contents: read
Expand All @@ -20,14 +20,13 @@ jobs:
name: GolangCI-Lint
runs-on:
group: Default
timeout-minutes: 5
timeout-minutes: 15
steps:
- uses: actions/checkout@v4 # v3.5.0
- uses: actions/setup-go@v5 # v4.0.0
with:
go-version-file: 'go.mod'
- run: go mod download
- run: make
- name: Run linters
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
Expand Down
37 changes: 16 additions & 21 deletions .github/workflows/new-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,22 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: latest
# TODO: Add testsunit / coverage
# testsunit:
# needs: [pre-check]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# token: ${{ secrets.CHANGELOG_PAT }}
# ref: ${{ github.ref }}
# - uses: actions/setup-go@v5
# with:
# go-version-file: 'go.mod'
# - run: go mod download
# - name: Run Go unit tests
# env:
# TEST_CLOUDAVENUE_ORG: ${{ secrets.CLOUDAVENUE_ORG }}
# TEST_CLOUDAVENUE_USERNAME: ${{ secrets.CLOUDAVENUE_USER }}
# TEST_CLOUDAVENUE_PASSWORD: ${{ secrets.CLOUDAVENUE_PASSWORD }}
# TEST_CLOUDAVENUE_VDC: ${{ secrets.CLOUDAVENUE_VDC }}
# run: |
# go test $(go list ./... | grep -v /internal/testsacc/)
testsunit:
needs: [pre-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CHANGELOG_PAT }}
ref: ${{ github.ref }}
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: go mod download
- name: Run Go unit tests
env:
run: |
go test $(go list ./... | grep -v /internal/registry)

# * Step 2: Create a new tag
tag:
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ issues:
max-same-issues: 0
exclude-dirs-use-default: false

run:
timeout: 10m

linters:
enable:
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 0.0.2 (Unreleased)

## 0.0.1 (October 17, 2024)

### :rocket: Initial release
76 changes: 40 additions & 36 deletions api/v1alpha1/kimup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type (
// KimupSpec defines the desired state of Kimup
KimupSpec struct {
// TODO add namespace and serviceaccount settings

// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the controller settings
// Controller is a map of settings that will be used to configure the controller. If not set, the controller will not be deployed.
Controller *KimupControllerSpec `json:"controller"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the admissionController settings
// AdmissionController is a map of settings that will be used to configure the admissionController. If not set, the admissionController will not be deployed.
AdmissionController *KimupAdmissionControllerSpec `json:"admissionController"`
}

Expand All @@ -42,8 +43,6 @@ type (
KimupInstanceSpec `json:",inline"`

KimupExtraSpec `json:",inline"`

// Service *KimupServiceSpec `json:"service,omitempty"`
}

// ! AdmissionController
Expand All @@ -52,11 +51,13 @@ type (
// +kubebuilder:validation:Optional
// +kubebuilder:default:=Deployment
// +kubebuilder:validation:Enum=Deployment;DaemonSet
// +kubebuilder:description: Type of deployment for the admissionController. (default: Deployment)
DeploymentType string `json:"deploymentType,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default:=3
// +kubebuilder:description: Number of replicas (default: 3) for the admissionController deployment. (Only for Deployment)
// Replicas is the number of replicas that will be used by the admissionController deployment. If not set, 3 replicas will be used. (Only for Deployment)
Replicas int32 `json:"replicas,omitempty"`

KimupInstanceSpec `json:",inline"`
Expand All @@ -70,109 +71,112 @@ type (
// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the metrics settings
// +kubebuilder:default:={enabled:true}
// Metrics is a map of settings that will be used to configure the metrics probe. If not set, the probe will be enabled.
Metrics KimupProbeSpec `json:"metrics,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the healthz settings
// +kubebuilder:default:={enabled:true}
// Healthz is a map of settings that will be used to configure the healthz probe. If not set, the probe will be enabled.
Healthz KimupProbeSpec `json:"healthz,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the log level settings
// +kubebuilder:default:=info
// +kubebuilder:validation:Enum=debug;info;warn;error
// +kubebuilder:validation:Enum=debug;info;warn;error;fatal;panic;trace
// LogLevel is a string that will be used to configure the log level of the Kimup instance. If not set, the info log level will be used.
LogLevel string `json:"logLevel,omitempty"`
}

KimupProbeSpec struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default:=true
// +kubebuilder:description: Enable or disable the probe
// Enabled is a boolean that enables or disables the probe. If not set, the probe will be enabled.
Enabled bool `json:"enabled,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the port settings
// Port is the port number where the probe will be exposed. If not set, the default port will be used. See https://pkg.go.dev/github.com/orange-cloudavenue/kube-image-updater@v0.0.1/internal/models#pkg-variables.
Port int32 `json:"port,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Manage the path settings
// Path is the path where the probe will be exposed. If not set, the default path will be used. See https://pkg.go.dev/github.com/orange-cloudavenue/kube-image-updater@v0.0.1/internal/models#pkg-variables.
Path string `json:"path,omitempty"`
}

// ! Instance

KimupInstanceSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:description: Kimup instance name
// The name of the Kimup instance in the suffix of the resource names.
Name string `json:"name"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Kimup container image
// Image of the Kimup container. If not set, the default image will be used.
Image string `json:"image,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Annotations to add to the Kimup pods.
// Annotations is a key value map that will be added to the Kimup pods.
Annotations map[string]string `json:"annotations,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Labels to add to the Kimup pods.
// Labels is a key value map that will be added to the Kimup pods.
Labels map[string]string `json:"labels,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Env variables to add to the Kimup pods.
// Env is a list of key value pairs that will be added to the Kimup pods.
Env []corev1.EnvVar `json:"env,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Kimup container resource limits.
// Resources is a map of resource requirements that will be added to the Kimup pods.
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Affinity settings for the Kimup pods.
// Affinity is a map of affinity settings that will be added to the Kimup pods.
Affinity *corev1.Affinity `json:"affinity,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Node selector for the Kimup pods.
// NodeSelector is a map of node selector settings that will be added to the Kimup pods.
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Tolerations for the Kimup pods.
// Tolerations is a list of tolerations that will be added to the Kimup pods.
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: TopologySpreadConstraints for the Kimup pods.
// TopologySpreadConstraints is a list of constraints that will be added to the Kimup pods.
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Service account name for the Kimup pods.
// +kubebuilder:default:=kimup
// ServiceAccountName is the name of the service account that will be used by the Kimup pods.
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description: Priority class name for the Kimup pods.
// PriorityClassName is the name of the priority class that will be used by the Kimup pods.
PriorityClassName string `json:"priorityClassName,omitempty"`
}

// ! Service

// KimupServiceSpec struct {
// // +kubebuilder:validation:Optional
// // +kubebuilder:description: Type of the Kimup service
// Type corev1.ServiceType `json:"type,omitempty"`

// // +kubebuilder:validation:Optional
// // +kubebuilder:description: Name of the Kimup service
// Name string `json:"name,omitempty"`

// // +kubebuilder:validation:Optional
// // +kubebuilder:description: Port for the Kimup service
// Port int32 `json:"port,omitempty"`

// // +kubebuilder:validation:Optional
// // +kubebuilder:description: Annotations to add to the Kimup service.
// Annotations map[string]string `json:"annotations,omitempty"`

// // +kubebuilder:validation:Optional
// // +kubebuilder:description: Labels to add to the Kimup service.
// Labels map[string]string `json:"labels,omitempty"`
// }

// KimupStatus defines the observed state of Kimup
// Status defines the observed state of Kimup
KimupStatus struct {
// Controller status
Controller KimupInstanceStatus `json:"controller,omitempty"`

// AdmissionController status
AdmissionController KimupInstanceStatus `json:"admissionController,omitempty"`
}

Expand All @@ -182,23 +186,23 @@ type (
// - "ready": The kimup instance is ready to serve requests
// - "resources-created": The Kimup instance resources were created but not yet configured
State string `json:"state,omitempty"`

// IsRollingUpdate is true if the kimup instance is being updated
IsRollingUpdate bool `json:"isRollingUpdate,omitempty"`
}
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// Kimup is the Schema for the kimups API
// +kubebuilder:printcolumn:name="Controller",type=string,JSONPath=`.status.controller.state`
// +kubebuilder:printcolumn:name="AdmissionController",type=string,JSONPath=`.status.admissionController.state`
// Kimup is the Schema for the kimups API. Permit to manage the Kimup instances. (Controller and AdmissionController)
type Kimup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KimupSpec `json:"spec,omitempty"`
// Spec defines the desired state of Kimup
Spec KimupSpec `json:"spec,omitempty"`

// Status defines the observed state of Kimup
Status KimupStatus `json:"status,omitempty"`
}

Expand Down
13 changes: 13 additions & 0 deletions docs/actions/alerts/discord-alert-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kimup.cloudavenue.io/v1alpha1
kind: AlertConfig
metadata:
name: demo
spec:
discord:
webhookURL: # (1)
valueFrom: # (2)
secretKeyRef:
name: discord-secret
key: webhookURL
templateBody: | # (3)
New dev version {{ .NewTag }} is available for {{ .ImageName }}.
22 changes: 3 additions & 19 deletions docs/actions/alerts/discord.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ kubectl apply -f discord-secret.yaml
```

**2 - Create AlertConfig**

<!-- Loaded from file because the vars in template are rendered by mkdocs-macros plugins and generate a error -->
```yaml hl_lines="6-13"
apiVersion: kimup.cloudavenue.io/v1alpha1
kind: AlertConfig
metadata:
name: demo
spec:
discord:
webhookURL: # (1)
valueFrom: # (2)
secretKeyRef:
name: discord-secret
key: webhookURL
templateBody: | # (3)
New dev version {{ .NewTag }} is available for {{ .ImageName }}.
--8<-- "docs/actions/alerts/discord-alert-config.yaml"
```

1. The `webhookURL` is the URL of the Discord webhook. [How to create a Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
Expand Down Expand Up @@ -84,8 +72,4 @@ spec:

## Fields

| Field | Description | Mandatory | Default |
|-------|-------------|:-----------:|---------|
| `webhookURL` | The URL of the Discord webhook. | :white_check_mark: | |
| `templateBody` | The custom message. | | [Default message](getting-start.md#template-body-alert-message) |
| `templateFile` | The path to the custom message file. | | |
See the list of fields available for the `discord` alert on [doc.crds.dev](https://doc.crds.dev/github.com/orange-cloudavenue/kube-image-updater/kimup.cloudavenue.io/AlertConfig/v1alpha1@{{git.short_tag}}#discord)
Loading
Loading