github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/edge/pkg/edged/clcm/clcm_policy_none.go (about) 1 /* 2 Copyright 2016 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 @CHANGELOG 17 KubeEdge Authors: To create mini-kubelet for edge deployment scenario, 18 This file is derived from K8S Kubelet code with reduced set of methods 19 */ 20 21 package clcm 22 23 import ( 24 "time" 25 26 v1 "k8s.io/api/core/v1" 27 "k8s.io/klog" 28 "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager" 29 "k8s.io/kubernetes/pkg/kubelet/cm/cpuset" 30 ) 31 32 const ( 33 //PolicyNone define no policy 34 PolicyNone = "none" 35 reconcilePeriod = 1 * time.Second 36 ) 37 38 type containerLifecycleManagerImpl struct { 39 cpuManager cpumanager.Manager 40 } 41 42 var _ ContainerLifecycleManager = &containerLifecycleManagerImpl{} 43 44 // NewContainerLifecycleManager create new object for container lifecycle manager 45 func NewContainerLifecycleManager(kubeletRootDir string) (ContainerLifecycleManager, error) { 46 var err error 47 clcm := &containerLifecycleManagerImpl{} 48 result := make(v1.ResourceList) 49 clcm.cpuManager, err = cpumanager.NewManager( 50 PolicyNone, 51 reconcilePeriod, 52 nil, 53 nil, 54 cpuset.NewCPUSet(), 55 result, 56 kubeletRootDir, 57 nil, 58 ) 59 if err != nil { 60 klog.Errorf("failed to initialize cpu manager: %v", err) 61 return nil, err 62 } 63 return clcm, nil 64 } 65 66 func (clcm *containerLifecycleManagerImpl) InternalContainerLifecycle() InternalContainerLifecycle { 67 return &internalContainerLifecycleImpl{clcm.cpuManager} 68 }