istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/kube/inject/initializer.go (about) 1 // Copyright Istio Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package inject 16 17 import ( 18 openshiftv1 "github.com/openshift/api/apps/v1" 19 appsv1 "k8s.io/api/apps/v1" 20 batchv1 "k8s.io/api/batch/v1" 21 v1 "k8s.io/api/core/v1" 22 "k8s.io/apimachinery/pkg/runtime" 23 "k8s.io/apimachinery/pkg/runtime/schema" 24 25 "istio.io/istio/pkg/config/constants" 26 "istio.io/istio/pkg/util/sets" 27 ) 28 29 // IgnoredNamespaces contains the system namespaces referenced from Kubernetes: 30 // Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#viewing-namespaces 31 // "kube-system": The namespace for objects created by the Kubernetes system. 32 // "kube-public": This namespace is mostly reserved for cluster usage. 33 // "kube-node-lease": This namespace for the lease objects associated with each node 34 // which improves the performance of the node heartbeats as the cluster scales. 35 // "local-path-storage": Dynamically provisioning persistent local storage with Kubernetes. 36 // 37 // used with Kind cluster: https://github.com/rancher/local-path-provisioner 38 var IgnoredNamespaces = sets.New( 39 constants.KubeSystemNamespace, 40 constants.KubePublicNamespace, 41 constants.KubeNodeLeaseNamespace, 42 constants.LocalPathStorageNamespace) 43 44 var ( 45 kinds = []struct { 46 groupVersion schema.GroupVersion 47 obj runtime.Object 48 resource string 49 apiPath string 50 }{ 51 {v1.SchemeGroupVersion, &v1.ReplicationController{}, "replicationcontrollers", "/api"}, 52 {v1.SchemeGroupVersion, &v1.Pod{}, "pods", "/api"}, 53 54 {appsv1.SchemeGroupVersion, &appsv1.Deployment{}, "deployments", "/apis"}, 55 {appsv1.SchemeGroupVersion, &appsv1.DaemonSet{}, "daemonsets", "/apis"}, 56 {appsv1.SchemeGroupVersion, &appsv1.ReplicaSet{}, "replicasets", "/apis"}, 57 58 {batchv1.SchemeGroupVersion, &batchv1.Job{}, "jobs", "/apis"}, 59 {batchv1.SchemeGroupVersion, &batchv1.CronJob{}, "cronjobs", "/apis"}, 60 61 {appsv1.SchemeGroupVersion, &appsv1.StatefulSet{}, "statefulsets", "/apis"}, 62 63 {v1.SchemeGroupVersion, &v1.List{}, "lists", "/apis"}, 64 65 {openshiftv1.GroupVersion, &openshiftv1.DeploymentConfig{}, "deploymentconfigs", "/apis"}, 66 } 67 injectScheme = runtime.NewScheme() 68 ) 69 70 func init() { 71 for _, kind := range kinds { 72 injectScheme.AddKnownTypes(kind.groupVersion, kind.obj) 73 injectScheme.AddUnversionedTypes(kind.groupVersion, kind.obj) 74 } 75 }