-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the vpc-nat generic configurations into one single ConfigMap (#2574
) * move the vpc-nat generic configurations into one single ConfigMap * make vpc-nat image name configurable --------- Co-authored-by: 夜微澜 <qiutingjun@cmss.chinamobile.com>
- Loading branch information
1 parent
887df21
commit 279717c
Showing
12 changed files
with
148 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: ovn-vpc-nat-config | ||
namespace: kube-system | ||
annotations: | ||
kubernetes.io/description: | | ||
kube-ovn vpc-nat common config | ||
data: | ||
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.kubeovn.vpcRepository }}:{{ .Values.global.images.kubeovn.tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package controller | ||
|
||
import ( | ||
k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/klog/v2" | ||
|
||
"github.com/kubeovn/kube-ovn/pkg/util" | ||
) | ||
|
||
var ( | ||
vpcNatImage = "" | ||
) | ||
|
||
func (c *Controller) resyncVpcNatConfig() { | ||
cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig) | ||
if err != nil && !k8serrors.IsNotFound(err) { | ||
klog.Errorf("failed to get ovn-vpc-nat-config, %v", err) | ||
return | ||
} | ||
vpcNatImage = cm.Data["image"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package webhook | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/types" | ||
|
||
"github.com/kubeovn/kube-ovn/pkg/util" | ||
) | ||
|
||
func (v *ValidatingHook) ValidateVpcNatConfig(ctx context.Context) error { | ||
cm := &corev1.ConfigMap{} | ||
cmKey := types.NamespacedName{Namespace: "kube-system", Name: util.VpcNatConfig} | ||
if err := v.cache.Get(ctx, cmKey, cm); err != nil { | ||
if k8serrors.IsNotFound(err) { | ||
return fmt.Errorf("configMap \"%s\" not configured", util.VpcNatConfig) | ||
} | ||
return err | ||
} | ||
|
||
if cm.Data["image"] == "" { | ||
err := fmt.Errorf("parameter \"image\" in ConfigMap \"%s\" cannot be empty", util.VpcNatConfig) | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.