Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chart/values.global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ controllerManager:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --namespace=llmaz-system
replicas: 1
1 change: 1 addition & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ controllerManager:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --namespace=llmaz-system
containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
5 changes: 4 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't, let's make sure this variables only available in main function for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok ,i revert this soon.

var namespace string

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.StringVar(&namespace, "namespace", "llmaz-system", "The namespace of the llmaz to deploy")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand Down Expand Up @@ -99,7 +102,7 @@ func main() {

certsReady := make(chan struct{})

if err = cert.CertsManager(mgr, certsReady); err != nil {
if err = cert.CertsManager(mgr, namespace, certsReady); err != nil {
setupLog.Error(err, "unable to setup cert rotation")
os.Exit(1)
}
Expand Down
1 change: 1 addition & 0 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ spec:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--leader-elect"
- "--namespace=llmaz-system"
10 changes: 4 additions & 6 deletions pkg/cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
)

const (
secretNamespace = "llmaz-system"
serviceName = "llmaz-webhook-service"
secretName = "llmaz-webhook-server-cert"
certDir = "/tmp/k8s-webhook-server/serving-certs"
Expand All @@ -32,18 +31,17 @@ const (
caOrg = "llmaz"
)

// dnsName is the format of <service name>.<namespace>.svc
var dnsName = fmt.Sprintf("%s.%s.svc", serviceName, secretNamespace)

//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;update
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=mutatingwebhookconfigurations,verbs=get;list;watch;update
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=validatingwebhookconfigurations,verbs=get;list;watch;update

// CertsManager creates certs for webhooks.
func CertsManager(mgr ctrl.Manager, setupFinish chan struct{}) error {
func CertsManager(mgr ctrl.Manager, namespace string, setupFinish chan struct{}) error {
// dnsName is the format of <service name>.<namespace>.svc
dnsName := fmt.Sprintf("%s.%s.svc", serviceName, namespace)
return cert.AddRotator(mgr, &cert.CertRotator{
SecretKey: types.NamespacedName{
Namespace: secretNamespace,
Namespace: namespace,
Name: secretName,
},
CertDir: certDir,
Expand Down