No more netpols fo pods in open namespaces.
This commit is contained in:
parent
6d05f0501f
commit
933b46c68c
@ -56,7 +56,7 @@ type Application struct {
|
|||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Ports []Port `yaml:"ports,omitempty"`
|
Ports []Port `yaml:"ports,omitempty"`
|
||||||
MatchLabels map[string]string `yaml:"matchLabels"`
|
MatchLabels map[string]string `yaml:"matchLabels"`
|
||||||
Namespace string `yaml:"-"`
|
Namespace *Namespace `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Namespace struct {
|
type Namespace struct {
|
||||||
@ -180,7 +180,7 @@ func LoadConfig(file string) (*Config, error) {
|
|||||||
// every application must have its namespace field set
|
// every application must have its namespace field set
|
||||||
for _, ns := range config.Namespaces {
|
for _, ns := range config.Namespaces {
|
||||||
for _, app := range ns.Applications {
|
for _, app := range ns.Applications {
|
||||||
app.Namespace = ns.Name
|
app.Namespace = ns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ func (g NetworkPolicyGenerrator) GenerateCommunicationRule(
|
|||||||
log.Printf("Found template %v for pod %s", tmpl, app.Name)
|
log.Printf("Found template %v for pod %s", tmpl, app.Name)
|
||||||
if tmpl != nil {
|
if tmpl != nil {
|
||||||
|
|
||||||
log.Printf("EXECUTING %s", app.Namespace)
|
|
||||||
err := tmpl.Execute(writer, map[string]any{
|
err := tmpl.Execute(writer, map[string]any{
|
||||||
"app": app,
|
"app": app,
|
||||||
"ingress": ingress,
|
"ingress": ingress,
|
||||||
|
@ -35,11 +35,12 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if not .app.Namespace.Open }}
|
||||||
kind: NetworkPolicy
|
kind: NetworkPolicy
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: "{{.app.Name}}"
|
name: "{{.app.Name}}"
|
||||||
namespace: "{{.app.Namespace}}"
|
namespace: "{{.app.Namespace.Name }}"
|
||||||
labels: {{ .labels | toYaml | nindent 4 }}
|
labels: {{ .labels | toYaml | nindent 4 }}
|
||||||
spec:
|
spec:
|
||||||
podSelector: {{ .app.MatchLabels | toYaml | nindent 4 }}
|
podSelector: {{ .app.MatchLabels | toYaml | nindent 4 }}
|
||||||
@ -65,4 +66,4 @@ spec:
|
|||||||
{{- template "networks" .egress }}
|
{{- template "networks" .egress }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
THEEND
|
{{- end }}
|
||||||
|
@ -14,7 +14,7 @@ networks:
|
|||||||
|
|
||||||
namespaces:
|
namespaces:
|
||||||
- name: wamblee-org
|
- name: wamblee-org
|
||||||
open: true
|
open: false
|
||||||
capabilities:
|
capabilities:
|
||||||
- linkerd
|
- linkerd
|
||||||
applications:
|
applications:
|
||||||
|
Loading…
Reference in New Issue
Block a user