Skip to content

Commit

Permalink
pass in configurations from configmap
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Oct 2, 2023
1 parent 8535395 commit a3d085a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
func main() {
// We run the entrypoint based on how we were invoked.
switch filepath.Base(os.Args[0]) {
case "webmesh":
case "webmesh", "loopback":
plugin.Main(version.Version)
case "webmesh-cni-node":
node.Main(version.Version)
Expand Down
25 changes: 22 additions & 3 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -963,9 +963,8 @@ metadata:
name: webmesh-config
namespace: kube-system
data:
## TODO: Add the webmesh-cni-node configurations here as well to
## potentially override command line arguments and other defaults.
#
cluster-domain: "cluster.local"
pod-cidr: "10.42.0.0/24"
# The network config to install on each node.
cni-network-config: |-
{
Expand Down Expand Up @@ -1063,6 +1062,8 @@ spec:
name: cni-bin-dir
- mountPath: /host/etc/cni/net.d
name: cni-net-dir
- mountPath: /var/lib/cni/networks
name: host-local-net-dir
securityContext:
privileged: true
containers:
Expand All @@ -1084,6 +1085,18 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# Set the pod cidr based on the one we are running.
- name: POD_CIDR
valueFrom:
configMapKeyRef:
name: webmesh-config
key: pod-cidr
# Set the cluster domain based on the one we are running.
- name: CLUSTER_DOMAIN
valueFrom:
configMapKeyRef:
name: webmesh-config
key: cluster-domain
volumeMounts:
- mountPath: /lib/modules
name: lib-modules
Expand All @@ -1103,3 +1116,9 @@ spec:
- name: cni-net-dir
hostPath:
path: /etc/cni/net.d
# Mount in the directory for host-local IPAM allocations. This is
# used when upgrading from host-local to calico-ipam, and can be removed
# if not using the upgrade-ipam init container.
- name: host-local-net-dir
hostPath:
path: /var/lib/cni/networks
17 changes: 14 additions & 3 deletions deploy/cni/cni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ metadata:
name: webmesh-config
namespace: kube-system
data:
## TODO: Add the webmesh-cni-node configurations here as well to
## potentially override command line arguments and other defaults.
#
cluster-domain: "cluster.local"
pod-cidr: "10.42.0.0/24"
# The network config to install on each node.
cni-network-config: |-
{
Expand Down Expand Up @@ -129,6 +128,18 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# Set the pod cidr based on the one we are running.
- name: POD_CIDR
valueFrom:
configMapKeyRef:
name: webmesh-config
key: pod-cidr
# Set the cluster domain based on the one we are running.
- name: CLUSTER_DOMAIN
valueFrom:
configMapKeyRef:
name: webmesh-config
key: cluster-domain
volumeMounts:
- mountPath: /lib/modules
name: lib-modules
Expand Down
12 changes: 7 additions & 5 deletions internal/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ func Main(version string) {
os.Exit(1)
}
// Copy the binary to the destination directory.
pluginBin := filepath.Join(os.Getenv(BinaryDestBinEnvVar), PluginBinaryName)
log.Println("installing plugin binary to -> ", pluginBin)
if err := installPluginBinary(exec, pluginBin); err != nil {
log.Println("error copying binary:", err)
os.Exit(1)
for _, binName := range []string{PluginBinaryName, "loopback"} {
pluginBin := filepath.Join(os.Getenv(BinaryDestBinEnvVar), binName)
log.Println("installing plugin binary to -> ", pluginBin)
if err := installPluginBinary(exec, pluginBin); err != nil {
log.Println("error copying binary:", err)
os.Exit(1)
}
}
// Write a kubeconfig file to the destination directory.
kubeconfigPath := filepath.Join(os.Getenv(BinaryDestBinEnvVar), "webmesh-kubeconfig")
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func Main(version string) {
)
flag.StringVar(&namespace, "namespace", os.Getenv(install.PodNamespaceEnvVar), "The namespace to use for the webmesh resources.")
flag.StringVar(&nodeID, "node-id", os.Getenv(install.NodeNameEnvVar), "The node ID to use for the webmesh cluster.")
flag.StringVar(&podCIDR, "pod-cidr", "172.16.0.0/12", "The pod CIDR to use for the webmesh cluster.")
flag.StringVar(&clusterDomain, "cluster-domain", "cluster.local", "The cluster domain to use for the webmesh cluster.")
flag.StringVar(&podCIDR, "pod-cidr", os.Getenv("POD_CIDR"), "The pod CIDR to use for the webmesh cluster.")
flag.StringVar(&clusterDomain, "cluster-domain", os.Getenv("CLUSTER_DOMAIN"), "The cluster domain to use for the webmesh cluster.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.DurationVar(&leaderElectLeaseDuration, "leader-elect-lease-duration", time.Second*15, "The duration that non-leader candidates will wait to force acquire leadership.")
Expand Down

0 comments on commit a3d085a

Please sign in to comment.