-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add mutating webhook for OSP and MD * Add validation for OSP Signed-off-by: Waleed Malik <[email protected]> * Add validations in OSP * Add vanilla manifests for deployment OSM and webhook * Bump GO to v1.17.6 * Bump GO to v1.17.5 Signed-off-by: Waleed Malik <[email protected]> * Use quay.io for images * Add deployment for osm-controller and webhook * Use dedicated client for interactions with seed and user clusters * Refactored code * Update test data * Update generated code Signed-off-by: Waleed Malik <[email protected]> * test changes * Fix codegen * Fix path for tls cert * Fix deployments and use external client for osc controller * Remove dependencies from ValidateMachineDeployment method to make it re-usable * Refactored code; handle PR feedback * User worker manager for OSC controller * Handle PR feedback
- Loading branch information
1 parent
3ded3fb
commit dcbfc27
Showing
43 changed files
with
1,746 additions
and
366 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
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,96 @@ | ||
/* | ||
Copyright 2021 The Operating System Manager contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
|
||
clusterv1alpha1 "github.com/kubermatic/machine-controller/pkg/apis/cluster/v1alpha1" | ||
"k8c.io/operating-system-manager/pkg/admission" | ||
"k8c.io/operating-system-manager/pkg/crd/osm/v1alpha1" | ||
|
||
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/klog" | ||
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
) | ||
|
||
type options struct { | ||
namespace string | ||
|
||
admissionListenAddress string | ||
admissionTLSCertPath string | ||
admissionTLSKeyPath string | ||
} | ||
|
||
var ( | ||
scheme = runtime.NewScheme() | ||
) | ||
|
||
func init() { | ||
utilruntime.Must(v1alpha1.AddToScheme(scheme)) | ||
utilruntime.Must(clusterv1alpha1.AddToScheme(scheme)) | ||
} | ||
|
||
func main() { | ||
klog.InitFlags(nil) | ||
|
||
opt := &options{} | ||
|
||
flag.StringVar(&opt.admissionListenAddress, "listen-address", ":9876", "The address on which the MutatingWebhook will listen on") | ||
flag.StringVar(&opt.admissionTLSCertPath, "tls-cert-path", "/tmp/cert/cert.pem", "The path of the TLS cert for the MutatingWebhook") | ||
flag.StringVar(&opt.admissionTLSKeyPath, "tls-key-path", "/tmp/cert/key.pem", "The path of the TLS key for the MutatingWebhook") | ||
flag.StringVar(&opt.namespace, "namespace", "", "The namespace where the OSC webhook will run.") | ||
flag.Parse() | ||
|
||
if len(opt.namespace) == 0 { | ||
klog.Fatal("-namespace is required") | ||
} | ||
|
||
// Build config for in-cluster cluster | ||
cfg, err := config.GetConfig() | ||
if err != nil { | ||
klog.Fatalf("error building kubeconfig: %v", err) | ||
} | ||
|
||
// Build client against in-cluster config | ||
client, err := ctrlruntimeclient.New(cfg, ctrlruntimeclient.Options{ | ||
Scheme: scheme, | ||
}) | ||
if err != nil { | ||
klog.Fatalf("failed to build seed client: %v", err) | ||
} | ||
|
||
srv, err := admission.New(opt.admissionListenAddress, opt.namespace, client) | ||
if err != nil { | ||
klog.Fatalf("failed to create admission hook: %v", err) | ||
} | ||
|
||
klog.Infof("starting webhook server on %s", opt.admissionListenAddress) | ||
|
||
if err := srv.ListenAndServeTLS(opt.admissionTLSCertPath, opt.admissionTLSKeyPath); err != nil { | ||
klog.Fatalf("failed to start server: %v", err) | ||
} | ||
defer func() { | ||
if err := srv.Close(); err != nil { | ||
klog.Fatalf("failed to shutdown server: %v", err) | ||
} | ||
}() | ||
klog.Infof("Listening on %s", opt.admissionListenAddress) | ||
select {} | ||
} |
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
Oops, something went wrong.