-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add internal-cert-controller disable flag #2426
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,18 +17,24 @@ limitations under the License. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
package main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"crypto/tls" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"errors" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"flag" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"net/http" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"os" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmapi "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
zaplog "go.uber.org/zap" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"go.uber.org/zap/zapcore" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
apiruntime "k8s.io/apimachinery/pkg/runtime" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ctrl "sigs.k8s.io/controller-runtime" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"sigs.k8s.io/controller-runtime/pkg/client" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"sigs.k8s.io/controller-runtime/pkg/controller" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"sigs.k8s.io/controller-runtime/pkg/healthz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -38,17 +44,12 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
schedulerpluginsv1alpha1 "sigs.k8s.io/scheduler-plugins/apis/scheduling/v1alpha1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
kubeflowv2 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/kubeflow/training-operator/pkg/cert" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
controllerv2 "github.com/kubeflow/training-operator/pkg/controller.v2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runtime "github.com/kubeflow/training-operator/pkg/runtime.v2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runtimecore "github.com/kubeflow/training-operator/pkg/runtime.v2/core" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
webhookv2 "github.com/kubeflow/training-operator/pkg/webhook.v2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
webhookConfigurationName = "validator.training-operator-v2.kubeflow.org" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scheme = apiruntime.NewScheme() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setupLog = ctrl.Log.WithName("setup") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -67,6 +68,7 @@ func main() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
var probeAddr string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var secureMetrics bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var enableHTTP2 bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var namespace string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var webhookServerPort int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var webhookServiceName string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var webhookSecretName string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -128,12 +130,8 @@ func main() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
certsReady := make(chan struct{}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err = cert.ManageCerts(mgr, cert.Config{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WebhookSecretName: webhookSecretName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WebhookServiceName: webhookServiceName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WebhookConfigurationName: webhookConfigurationName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, certsReady); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setupLog.Error(err, "unable to set up cert rotation") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err := createCertificate(mgr.GetClient(), namespace, webhookSecretName, webhookServiceName); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want this to be configurable, so cert-manager is an option, not a requirement? My understanding is we still want it possible to install Kubeflow trainer without cert-manager. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cert-manager is optional. We should not create resources automatically in manager. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tenzen-y can you please brief if any changes are required in current PR ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned the previous comment, we should not remove and replace the existing CertManagement mechanism. We just provide the command flag whether or not manager uses internal-certmanagement mechanism.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tenzen-y yes i will revert the code back to cert generation by controller There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setupLog.Error(err, "Unable to create CertManager certificate") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
os.Exit(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -155,6 +153,34 @@ func main() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Cert generation Using cert-manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func createCertificate(client client.Client, namespace, secretName, serviceName string) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cert := &cmapi.Certificate{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ObjectMeta: metav1.ObjectMeta{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Name: secretName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Namespace: namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Spec: cmapi.CertificateSpec{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SecretName: secretName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IssuerRef: cmmeta.ObjectReference{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Name: "letsencrypt-prod", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Kind: "ClusterIssuer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CommonName: serviceName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DNSNames: []string{serviceName}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Usages: []cmapi.KeyUsage{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmapi.UsageServerAuth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmapi.UsageClientAuth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err := client.Create(context.Background(), cert); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return fmt.Errorf("failed to create certificate: %v", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+158
to
+185
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func setupControllers(mgr ctrl.Manager, runtimes map[string]runtime.Runtime, certsReady <-chan struct{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setupLog.Info("Waiting for certificate generation to complete") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<-certsReady | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small confusion should we use webhookConfigurationName instead of namespace(as of V1) ?