Skip to content

Commit

Permalink
Merge pull request #29 from expektorans/fix/get-ports
Browse files Browse the repository at this point in the history
Fix/get ports
  • Loading branch information
horazont authored Jun 8, 2022
2 parents 8179501 + fdf4a11 commit ca42626
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions docs/develop.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Develop
#######

Running ch-k8s-lbaas-controller locally
=======================================

During development you usually don't want to go through a full "Build Image / Push Image / Deploy Image" cycle - and you don't have to. As a shortcut you can run the controller locally on your workstation. You need

- a kubeconfig file which gives the controller the necessary permissions (you could just use your default `admin.conf`)
- the `controller-config.toml` which tells the controller how to interact with the OpenStack control plane. You can fetch it from the k8s control plane and place it in the same directory as the controller, e.g., via `kubectl get secret -n kube-system -o jsonpath='{.data.controller-config\.toml} | base64 -d > controller-config.toml'`

If you're using yaook/k8s, then you probably also have to adapt firewall rules on the (primary) gateway node. Add an entry such as `ip saddr 172.30.153.0/24 tcp dport $lbaas_agent_tcp_port accept;` to the file `/var/lib/ch-k8s-lbaas-agent/nftables/access.conf` and restart nftables via `sudo systemctl reload nftables`. Obviously that's an ephemeral change and you have to adapt the address range to your actual wireguard subnet.
6 changes: 3 additions & 3 deletions internal/openstack/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type UncachedClient struct {
}

type PortClient interface {
GetPorts() ([]*portsv2.Port, error)
GetPorts() ([]portsv2.Port, error)
GetPortByID(ID string) (*portsv2.Port, *floatingipsv2.FloatingIP, error)
}

Expand All @@ -47,7 +47,7 @@ func NewPortClient(networkingclient *gophercloud.ServiceClient, tag string, useF
}
}

func (pc *UncachedClient) GetPorts() (ports []*portsv2.Port, err error) {
func (pc *UncachedClient) GetPorts() (ports []portsv2.Port, err error) {
err = portsv2.List(
pc.client,
portsv2.ListOpts{Tags: pc.tag},
Expand All @@ -57,7 +57,7 @@ func (pc *UncachedClient) GetPorts() (ports []*portsv2.Port, err error) {
return false, err
}
for _, found_port := range fetched_ports {
ports = append(ports, &found_port)
ports = append(ports, found_port)
}
return true, nil
})
Expand Down

0 comments on commit ca42626

Please sign in to comment.