sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/config.go (about) 1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package manager 18 19 import ( 20 "path/filepath" 21 22 "sigs.k8s.io/kubebuilder/v3/pkg/machinery" 23 ) 24 25 var _ machinery.Template = &Config{} 26 27 // Config scaffolds a file that defines the namespace and the manager deployment 28 type Config struct { 29 machinery.TemplateMixin 30 31 // Image is controller manager image name 32 Image string 33 } 34 35 // SetTemplateDefaults implements file.Template 36 func (f *Config) SetTemplateDefaults() error { 37 if f.Path == "" { 38 f.Path = filepath.Join("config", "manager", "manager.yaml") 39 } 40 41 f.TemplateBody = configTemplate 42 43 return nil 44 } 45 46 const configTemplate = `apiVersion: v1 47 kind: Namespace 48 metadata: 49 labels: 50 control-plane: controller-manager 51 name: system 52 --- 53 apiVersion: apps/v1 54 kind: Deployment 55 metadata: 56 name: controller-manager 57 namespace: system 58 labels: 59 control-plane: controller-manager 60 spec: 61 selector: 62 matchLabels: 63 control-plane: controller-manager 64 replicas: 1 65 template: 66 metadata: 67 labels: 68 control-plane: controller-manager 69 spec: 70 containers: 71 - command: 72 - /manager 73 args: 74 - --enable-leader-election 75 image: {{ .Image }} 76 name: manager 77 resources: 78 limits: 79 cpu: 100m 80 memory: 30Mi 81 requests: 82 cpu: 100m 83 memory: 20Mi 84 terminationGracePeriodSeconds: 10 85 `