Skip to content

Commit

Permalink
Merge pull request #1434 from FabianKramm/main
Browse files Browse the repository at this point in the history
refactor: allow extra sans
  • Loading branch information
FabianKramm authored Dec 28, 2023
2 parents 8235e1b + ad119af commit bc8b1cd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/eks/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rules:
resources: ["features", "virtualclusters"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if or .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
{{- if or .Values.pro .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
- apiGroups: [""]
resources: ["nodes", "nodes/status"]
verbs: ["get", "watch", "list"]
Expand Down
2 changes: 1 addition & 1 deletion charts/k0s/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rules:
resources: ["features", "virtualclusters"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if or .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
{{- if or .Values.pro .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
- apiGroups: [""]
resources: ["nodes", "nodes/status"]
verbs: ["get", "watch", "list"]
Expand Down
2 changes: 1 addition & 1 deletion charts/k3s/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rules:
resources: ["features", "virtualclusters"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if or .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
{{- if or .Values.pro .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
- apiGroups: [""]
resources: ["nodes", "nodes/status"]
verbs: ["get", "watch", "list"]
Expand Down
2 changes: 1 addition & 1 deletion charts/k8s/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rules:
resources: ["features", "virtualclusters"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if or .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
{{- if or .Values.pro .Values.sync.nodes.enabled .Values.rbac.clusterRole.create }}
- apiGroups: [""]
resources: ["nodes", "nodes/status"]
verbs: ["get", "watch", "list"]
Expand Down
16 changes: 16 additions & 0 deletions pkg/server/cert/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

type ExtraSANsFunc func(ctx context.Context) ([]string, error)

// ExtraSANs can be used to add extra sans via a function
var ExtraSANs []ExtraSANsFunc

type Syncer interface {
dynamiccertificates.Notifier
dynamiccertificates.ControllerRunner
Expand Down Expand Up @@ -122,8 +127,19 @@ func (s *syncer) getSANs(ctx context.Context) ([]string, error) {
}
}

// add cluster ip
retSANs = append(retSANs, svc.Spec.ClusterIP)

// add extra sans
for _, extraSans := range ExtraSANs {
extraSansValues, err := extraSans(ctx)
if err != nil {
return nil, fmt.Errorf("error getting extra sans: %w", err)
}

retSANs = append(retSANs, extraSansValues...)
}

// add pod IP
podIP := os.Getenv("POD_IP")
if podIP != "" {
Expand Down

0 comments on commit bc8b1cd

Please sign in to comment.