Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "Init core to k8s", Long: `Init core to k8s`, Run: func(cmd *cobra.Command, args []string) { mod, _ := cmd.Flags().GetString("mod") log.Printf("successed to get mod: %v", mod) port, _ := cmd.Flags().GetString("port") name, _ := cmd.Flags().GetString("name") namespace, _ := cmd.Flags().GetString("namespace") intPort, err := strconv.Atoi(port) int32Value := int32(intPort) if err != nil { panic(err) } client, err := k8s.Client() if err != nil { panic(err.Error()) } var ( webhookHost string vc v1.WebhookClientConfig mc v1.WebhookClientConfig vcPath = "/v1/validate" mcPath = "/v1/inject" ) if mod == "debug" { webhookHost = "host.docker.internal" vcWebhookURL := fmt.Sprintf("https://%s:%s%s", webhookHost, port, vcPath) mcWebhookURL := fmt.Sprintf("https://%s:%s%s", webhookHost, port, mcPath) vc.URL = &vcWebhookURL mc.URL = &mcWebhookURL } if mod == "release" { webhookHost = fmt.Sprintf("%s.%s.svc", name, namespace) vc.Service = &v1.ServiceReference{ Namespace: namespace, Name: name, Path: &vcPath, Port: &int32Value, } mc.Service = &v1.ServiceReference{ Namespace: namespace, Name: name, Path: &mcPath, Port: &int32Value, } } generateSelfSignedCert(webhookHost) pemData, err := os.ReadFile(certFile) if err != nil { panic(err) } vc.CABundle = pemData mc.CABundle = pemData createValidatingWebhookConfig(name, client, vc) createMutatingWebhookConfig(name, client, mc) }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.