Skip to content

Commit

Permalink
Merge pull request kube-vip#894 from thebsdbox/manifest_fix
Browse files Browse the repository at this point in the history
Manifest fix
  • Loading branch information
thebsdbox authored Jul 11, 2024
2 parents 59951cb + 6f26746 commit a571d0a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
go-version-file: go.mod
- name: Build image locally
run: make dockerx86Local
- name: Run Manifest generation tests
run: make manifest-test
- name: Run Control plane tests
run: make e2e-tests
- name: Run Control plane tests v1.29.0 onwards
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ manifests:
@./kube-vip manifest daemonset --interface eth0 --vip 192.168.0.1 --bgp --leaderElection --controlplane --services --inCluster --provider-config /etc/cloud-sa/cloud-sa.json > ./docs/manifests/$(VERSION)/kube-vip-bgp-em-ds.yaml
@-rm ./kube-vip

manifest-test:
docker run $(REPOSITORY)/$(TARGET):$(DOCKERTAG) manifest pod --interface eth0 --vip 192.168.0.1 --arp --leaderElection --controlplane --services
docker run $(REPOSITORY)/$(TARGET):$(DOCKERTAG) manifest pod --interface eth0 --vip 192.168.0.1 --arp --leaderElection --controlplane --services --enableLoadBalancer
docker run $(REPOSITORY)/$(TARGET):$(DOCKERTAG) manifest pod --interface eth0 --vip 192.168.0.1 --bgp --controlplane --services
docker run $(REPOSITORY)/$(TARGET):$(DOCKERTAG) manifest daemonset --interface eth0 --vip 192.168.0.1 --arp --leaderElection --controlplane --services --inCluster
docker run $(REPOSITORY)/$(TARGET):$(DOCKERTAG) manifest daemonset --interface eth0 --vip 192.168.0.1 --arp --leaderElection --controlplane --services --inCluster --enableLoadBalancer
docker run $(REPOSITORY)/$(TARGET):$(DOCKERTAG) manifest daemonset --interface eth0 --vip 192.168.0.1 --bgp --leaderElection --controlplane --services --inCluster

unit-tests:
go test ./...

Expand Down
14 changes: 7 additions & 7 deletions cmd/kube-vip-manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ var kubeManifestPod = &cobra.Command{
log.Fatalln("No address is specified for kube-vip to expose services on")
}

if initConfig.VIPCIDR == "" {
// Ensure there is an address to generate the CIDR from
if initConfig.VIPCIDR == "" && initConfig.Address != "" {
initConfig.VIPCIDR, err = generateCidrRange(initConfig.Address)

if err != nil {
log.Fatalln(err)
}
Expand Down Expand Up @@ -92,9 +92,9 @@ var kubeManifestDaemon = &cobra.Command{
log.Fatalln("No address is specified for kube-vip to expose services on")
}

if initConfig.VIPCIDR == "" {
// Ensure there is an address to generate the CIDR from
if initConfig.VIPCIDR == "" && initConfig.Address != "" {
initConfig.VIPCIDR, err = generateCidrRange(initConfig.Address)

if err != nil {
log.Fatalln(err)
}
Expand Down Expand Up @@ -125,9 +125,9 @@ var kubeManifestRbac = &cobra.Command{
log.Fatalln("No address is specified for kube-vip to expose services on")
}

if initConfig.VIPCIDR == "" {
// Ensure there is an address to generate the CIDR from
if initConfig.VIPCIDR == "" && initConfig.Address != "" {
initConfig.VIPCIDR, err = generateCidrRange(initConfig.Address)

if err != nil {
log.Fatalln(err)
}
Expand All @@ -147,7 +147,7 @@ func generateCidrRange(address string) (string, error) {
ip := net.ParseIP(a)

if ip == nil {
return "", fmt.Errorf("invalid IP address: %v", a)
return "", fmt.Errorf("invalid IP address: %s from [%s]", a, address)
}

if ip.To4() != nil {
Expand Down
9 changes: 9 additions & 0 deletions pkg/kubevip/config_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,15 @@ func GenerateDaemonsetManifestFromConfig(c *Config, imageVersion string, inClust
},
}
}

// TODO: we don't check error return values for any of these marshall/unmarshall functions
b, _ := yaml.Marshal(newManifest)

// This additional step is required to be able to delete a section of the manifest being generated
m := make(map[string]interface{})
_ = yaml.Unmarshal(b, &m)
delete(m, "status")

b, _ = yaml.Marshal(m)
return string(b)
}

0 comments on commit a571d0a

Please sign in to comment.