Skip to content

Commit fe12db6

Browse files
zongzwgitee-org
authored andcommitted
!42 Categorize input parameters; with yaml.v3
Merge pull request !42 from zongzw/zong-gopkg.in-yaml.v3
2 parents ec69489 + 90802aa commit fe12db6

File tree

10 files changed

+292
-353
lines changed

10 files changed

+292
-353
lines changed

controllers/v1_controller.go

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,24 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
103103
if err := r.Get(ctx, req.NamespacedName, &obj); err != nil {
104104
if client.IgnoreNotFound(err) == nil {
105105
k8s.NodeCache.Unset(req.Name)
106-
if ncfgs, err = pkg.ParseNodeConfigs(); err != nil {
107-
return ctrl.Result{}, err
108-
}
109-
pkg.PendingDeploys <- pkg.DeployRequest{
110-
Meta: fmt.Sprintf("refreshing for request '%s'", req.Name),
111-
From: &ocfgs,
112-
To: &ncfgs,
113-
StatusFunc: func() {},
114-
Partition: "Common",
115-
Context: lctx,
106+
for _, c := range pkg.BIPConfigs {
107+
if ncfgs, err = pkg.ParseNodeConfigs(&c); err != nil {
108+
return ctrl.Result{}, err
109+
}
110+
if c.Management.Port == nil {
111+
*c.Management.Port = 443
112+
}
113+
url := fmt.Sprintf("https://%s:%d", c.Management.IpAddress, *c.Management.Port)
114+
pkg.PendingDeploys <- pkg.DeployRequest{
115+
Meta: fmt.Sprintf("refreshing for request '%s'", req.Name),
116+
From: &ocfgs,
117+
To: &ncfgs,
118+
StatusFunc: func() {},
119+
Partition: "Common",
120+
Context: context.WithValue(lctx, pkg.CtxKey_SpecifiedBIGIP, url),
121+
}
116122
}
123+
117124
} else {
118125
return ctrl.Result{}, err
119126
}
@@ -124,16 +131,22 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
124131
if newa := k8s.NodeCache.Get(obj.Name); reflect.DeepEqual(orig, newa) {
125132
return ctrl.Result{}, nil
126133
}
127-
if ncfgs, err = pkg.ParseNodeConfigs(); err != nil {
128-
return ctrl.Result{}, err
129-
}
130-
pkg.PendingDeploys <- pkg.DeployRequest{
131-
Meta: fmt.Sprintf("refreshing for request '%s'", req.Name),
132-
From: &ocfgs,
133-
To: &ncfgs,
134-
StatusFunc: func() {},
135-
Partition: "Common",
136-
Context: lctx,
134+
for _, c := range pkg.BIPConfigs {
135+
if ncfgs, err = pkg.ParseNodeConfigs(&c); err != nil {
136+
return ctrl.Result{}, err
137+
}
138+
if c.Management.Port == nil {
139+
*c.Management.Port = 443
140+
}
141+
url := fmt.Sprintf("https://%s:%d", c.Management.IpAddress, *c.Management.Port)
142+
pkg.PendingDeploys <- pkg.DeployRequest{
143+
Meta: fmt.Sprintf("refreshing for request '%s'", req.Name),
144+
From: &ocfgs,
145+
To: &ncfgs,
146+
StatusFunc: func() {},
147+
Partition: "Common",
148+
Context: context.WithValue(lctx, pkg.CtxKey_SpecifiedBIGIP, url),
149+
}
137150
}
138151
}
139152
return ctrl.Result{}, nil

deploy/3.deploy-bigip-kubernetes-gateway-controller.yaml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
name: bigip-login
77
namespace: kube-system
88
data:
9-
password: UEBzc3cwcmQxMjM= # base64 encoded 'mypassword'
9+
password: UEBzc3cwcmQxMjM= # base64 encoded
1010
type: Opaque
1111

1212
---
@@ -17,24 +17,23 @@ metadata:
1717
name: bigip-kubernetes-gateway-configmap
1818
namespace: kube-system
1919
data:
20-
bigip-kubernetes-gateway-config.yaml: |
21-
bigips:
22-
- mgmtIpAddress: "10.50.17.104"
23-
vxlanProfileName: "fl-vxlan"
24-
vxlanPort: "8472"
25-
vxlanLocalAddress: "4.4.4.4"
26-
selfIpName: "flannel-self"
27-
selfIpAddress: "5.5.5.5/28"
28-
url: "https://10.50.17.104:8443"
29-
username: "admin"
30-
- mgmtIpAddress: "10.50.15.173"
31-
vxlanProfileName: "fl-vxlan"
32-
vxlanPort: "8472"
33-
vxlanLocalAddress: "4.4.4.5"
34-
selfIpName: "flannel-self"
35-
selfIpAddress: "5.5.5.6/28"
36-
url: "https://10.50.15.173:8443"
37-
username: "admin"
20+
bigip-kubernetes-gateway-config: |
21+
- management:
22+
username: admin
23+
ipAddress: 10.250.15.180
24+
port: 443
25+
flannel:
26+
tunnels:
27+
- name: fl-tunnel
28+
profileName: fl-vxlan
29+
port: 8472
30+
localAddress: 10.250.18.119
31+
selfIPs:
32+
- name: flannel-self
33+
ipMask: 10.42.20.1/16
34+
tunnelName: fl-tunnel
35+
# calico:
36+
# kindsOfConfigItems: ""
3837
3938
---
4039

go.mod

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/onsi/ginkgo/v2 v2.3.1
99
github.com/onsi/gomega v1.22.1
1010
github.com/prometheus/client_golang v1.13.0
11-
github.com/spf13/viper v1.14.0
11+
gopkg.in/yaml.v3 v3.0.1
1212
k8s.io/api v0.25.3
1313
k8s.io/apimachinery v0.25.3
1414
k8s.io/client-go v0.25.3
@@ -45,28 +45,20 @@ require (
4545
github.com/google/gnostic v0.5.7-v3refs // indirect
4646
github.com/google/go-cmp v0.5.9 // indirect
4747
github.com/google/gofuzz v1.1.0 // indirect
48-
github.com/hashicorp/hcl v1.0.0 // indirect
4948
github.com/imdario/mergo v0.3.12 // indirect
5049
github.com/josharian/intern v1.0.0 // indirect
5150
github.com/json-iterator/go v1.1.12 // indirect
52-
github.com/magiconair/properties v1.8.6 // indirect
5351
github.com/mailru/easyjson v0.7.6 // indirect
5452
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
55-
github.com/mitchellh/mapstructure v1.5.0 // indirect
5653
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5754
github.com/modern-go/reflect2 v1.0.2 // indirect
5855
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
59-
github.com/pelletier/go-toml v1.9.5 // indirect
60-
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
6156
github.com/pkg/errors v0.9.1 // indirect
6257
github.com/prometheus/client_model v0.2.0 // indirect
6358
github.com/prometheus/common v0.37.0 // indirect
6459
github.com/prometheus/procfs v0.8.0 // indirect
65-
github.com/spf13/afero v1.9.2 // indirect
66-
github.com/spf13/cast v1.5.0 // indirect
67-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
6860
github.com/spf13/pflag v1.0.5 // indirect
69-
github.com/subosito/gotenv v1.4.1 // indirect
61+
github.com/stretchr/testify v1.8.1 // indirect
7062
go.uber.org/atomic v1.9.0 // indirect
7163
go.uber.org/multierr v1.8.0 // indirect
7264
go.uber.org/zap v1.21.0 // indirect
@@ -81,9 +73,7 @@ require (
8173
google.golang.org/appengine v1.6.7 // indirect
8274
google.golang.org/protobuf v1.28.1 // indirect
8375
gopkg.in/inf.v0 v0.9.1 // indirect
84-
gopkg.in/ini.v1 v1.67.0 // indirect
8576
gopkg.in/yaml.v2 v2.4.0 // indirect
86-
gopkg.in/yaml.v3 v3.0.1 // indirect
8777
k8s.io/apiextensions-apiserver v0.25.0 // indirect
8878
k8s.io/component-base v0.25.0 // indirect
8979
k8s.io/klog/v2 v2.70.1 // indirect

0 commit comments

Comments
 (0)