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

refactor(vmi-router): Use IP from our VirtualMachine #69

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions images/base-golang-21-bookworm/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
image: {{ $.ImageName }}
from: docker.io/golang:1.21.8-bookworm@sha256:ac14cc827536ef1a124cd2f7a03178c3335c1db8ad3807e7fdd57f74096abfa0
41 changes: 41 additions & 0 deletions images/vmi-router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## vmi-router

> **NOTE:** Not an accurate name, should be 'cilium-route-updater'.

This controller watches for VirtualMachines in virtualization.deckhouse.io group and updates routes in table 1490 to route traffic between VMs via Cilium agents.

It should be run as a DaemonSet with the `hostNetwork: true` to be able to modify route tables on cluster Nodes.

### Configuration

#### Log verbosity

Set VERBOSITY environment variable or -v flag.

#### Route table ID

Hardcoded as integer `1490`.

#### CIDRs

Use --cidr flags to specify CIDRs to limit managed IPs. Controller will update routes for VMs which IPs belong to specified CIDRs.

Example:

```
vmi-router --cidr 10.2.0.0/24 --cidr 10.2.1.0/24 --cidr 10.2.2.0/24
```

Controller will update route for VM with IP 10.2.1.32, but will ignore VM with IP 10.2.4.5.

#### Dry run mode

Use --dry-run flag to enable non destructive mode. The controller will not actually delete or replace rules and routes, only log these actions.

#### Metrics and healthz addresses

Controller can't predict used ports when starting in host network mode. So, be default, metrics and healthz are started on random free ports. Use flags to specify these addresses:

`--metrics-bind-address` - set port for /metrics endpoint, e.g. `--metrics-bind-address=:9250`
`--health-probe-bind-address` - set port for /healthz endpoint, e.g. `--health-probe-bind-address=:9321`

10 changes: 3 additions & 7 deletions images/vmi-router/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
//+kubebuilder:scaffold:imports
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand All @@ -48,8 +47,8 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: false,
CRDDirectoryPaths: []string{filepath.Join("..", "..", "crds")},
ErrorIfCRDPathMissing: true,
}

var err error
Expand All @@ -58,13 +57,10 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

//+kubebuilder:scaffold:scheme

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())

}, 60)
})

var _ = AfterSuite(func() {
By("tearing down the test environment")
Expand Down
Loading
Loading