diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index c6366539883..38dfb22f3ac 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "net/http" + _ "net/http/pprof" "os" "os/exec" "strings" @@ -24,6 +26,9 @@ func main() { } go loopOvnNbctlDaemon(config) + go func() { + klog.Fatal(http.ListenAndServe(fmt.Sprintf("localhost:%d", config.PprofPort), nil)) + }() err = controller.InitClusterRouter(config) if err != nil { diff --git a/cmd/daemon/cniserver.go b/cmd/daemon/cniserver.go index e8472eef4f5..93333dda144 100644 --- a/cmd/daemon/cniserver.go +++ b/cmd/daemon/cniserver.go @@ -1,6 +1,9 @@ package main import ( + "fmt" + "net/http" + _ "net/http/pprof" "os" "time" @@ -36,6 +39,9 @@ func main() { } kubeInformerFactory.Start(stopCh) go ctl.Run(stopCh) + go func() { + klog.Fatal(http.ListenAndServe(fmt.Sprintf("localhost:%d", config.PprofPort), nil)) + }() daemon.RunServer(config) } diff --git a/pkg/controller/config.go b/pkg/controller/config.go index e73722ddf05..48be62380c7 100644 --- a/pkg/controller/config.go +++ b/pkg/controller/config.go @@ -37,6 +37,7 @@ type Configuration struct { PodNamespace string WorkerNum int + PprofPort int } // ParseFlags parses cmd args then init kubeclient and conf @@ -62,6 +63,7 @@ func ParseFlags() (*Configuration, error) { argClusterUdpLoadBalancer = pflag.String("cluster-udp-loadbalancer", "cluster-udp-loadbalancer", "The name for cluster udp loadbalancer") argWorkerNum = pflag.Int("worker-num", 3, "The parallelism of each worker, default: 3") + argPprofPort = pflag.Int("pprof-port", 10660, "The port to get profiling data, default 10660") ) flag.Set("alsologtostderr", "true") @@ -102,6 +104,7 @@ func ParseFlags() (*Configuration, error) { ClusterTcpLoadBalancer: *argClusterTcpLoadBalancer, ClusterUdpLoadBalancer: *argClusterUdpLoadBalancer, WorkerNum: *argWorkerNum, + PprofPort: *argPprofPort, PodName: os.Getenv("POD_NAME"), PodNamespace: os.Getenv("KUBE_NAMESPACE"), } diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index b2e05d35078..5bc038567f2 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -22,6 +22,7 @@ type Configuration struct { KubeClient kubernetes.Interface NodeName string ServiceClusterIPRange string + PprofPort int } // ParseFlags will parse cmd args then init kubeClient and configuration @@ -32,6 +33,7 @@ func ParseFlags() (*Configuration, error) { argOvsSocket = pflag.String("ovs-socket", "", "The socket to local ovs-server") argKubeConfigFile = pflag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information. If not set use the inCluster token.") argServiceClusterIPRange = pflag.String("service-cluster-ip-range", "10.96.0.0/12", "The kubernetes service cluster ip range") + argPprofPort = pflag.Int("pprof-port", 10665, "The port to get profiling data, default 10665") ) // mute log for ipset lib @@ -65,6 +67,7 @@ func ParseFlags() (*Configuration, error) { BindSocket: *argBindSocket, OvsSocket: *argOvsSocket, KubeConfigFile: *argKubeConfigFile, + PprofPort: *argPprofPort, NodeName: nodeName, ServiceClusterIPRange: *argServiceClusterIPRange, } diff --git a/yamls/kube-ovn.yaml b/yamls/kube-ovn.yaml index 3643b6664df..c3ca5e25efd 100644 --- a/yamls/kube-ovn.yaml +++ b/yamls/kube-ovn.yaml @@ -38,7 +38,7 @@ spec: hostNetwork: true containers: - name: kube-ovn-controller - image: "index.alauda.cn/alaudak8s/kube-ovn-controller:v0.4.1" + image: "index.alauda.cn/alaudak8s/kube-ovn-controller:v0.5.0-pre" imagePullPolicy: Always command: - /kube-ovn/start-controller.sh @@ -55,6 +55,26 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + readinessProbe: + exec: + command: + - nc + - -z + - -w3 + - 127.0.0.1 + - "10660" + periodSeconds: 3 + livenessProbe: + exec: + command: + - nc + - -z + - -w3 + - 127.0.0.1 + - "10660" + initialDelaySeconds: 30 + periodSeconds: 7 + failureThreshold: 5 nodeSelector: beta.kubernetes.io/os: "linux" @@ -88,7 +108,7 @@ spec: hostPID: true initContainers: - name: install-cni - image: "index.alauda.cn/alaudak8s/kube-ovn-cni:v0.4.1" + image: "index.alauda.cn/alaudak8s/kube-ovn-cni:v0.5.0-pre" imagePullPolicy: Always command: ["/kube-ovn/install-cni.sh"] volumeMounts: @@ -98,7 +118,7 @@ spec: name: cni-bin containers: - name: cni-server - image: "index.alauda.cn/alaudak8s/kube-ovn-cni:v0.4.1" + image: "index.alauda.cn/alaudak8s/kube-ovn-cni:v0.5.0-pre" imagePullPolicy: Always securityContext: runAsUser: 0 @@ -115,6 +135,26 @@ spec: volumeMounts: - mountPath: /run/openvswitch name: host-run-ovs + readinessProbe: + exec: + command: + - nc + - -z + - -w3 + - 127.0.0.1 + - "10665" + periodSeconds: 3 + livenessProbe: + exec: + command: + - nc + - -z + - -w3 + - 127.0.0.1 + - "10665" + initialDelaySeconds: 30 + periodSeconds: 7 + failureThreshold: 5 nodeSelector: beta.kubernetes.io/os: "linux" volumes: @@ -127,3 +167,4 @@ spec: - name: cni-bin hostPath: path: /opt/cni/bin + diff --git a/yamls/ovn.yaml b/yamls/ovn.yaml index f4f35a00707..6faeaccd9c0 100644 --- a/yamls/ovn.yaml +++ b/yamls/ovn.yaml @@ -170,7 +170,7 @@ spec: hostNetwork: true containers: - name: ovn-central - image: "index.alauda.cn/alaudak8s/kube-ovn-db:v0.4.1" + image: "index.alauda.cn/alaudak8s/kube-ovn-db:v0.5.0-pre" imagePullPolicy: Always env: - name: POD_IP @@ -257,7 +257,7 @@ spec: hostPID: true containers: - name: openvswitch - image: "index.alauda.cn/alaudak8s/kube-ovn-node:v0.4.1" + image: "index.alauda.cn/alaudak8s/kube-ovn-node:v0.5.0-pre" imagePullPolicy: Always securityContext: runAsUser: 0