utils

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

* Copyright The Kmesh Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Kmesh Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotationEnabled

func AnnotationEnabled(annotation string) bool

func AtomicCopy

func AtomicCopy(srcFilepath, targetDir, targetFilename string) error

AtomicCopy copies file by reading the file then writing atomically into the target directory

func AtomicWrite

func AtomicWrite(path string, data []byte, mode os.FileMode) error

create a temp file and rename to path

func CreateK8sClientSet

func CreateK8sClientSet(kubeconfig string) (kubernetes.Interface, error)

CreateK8sClientSet creates a Kubernetes clientset from a kubeconfig file

func DelKmeshRedirectAnnotation

func DelKmeshRedirectAnnotation(client kubernetes.Interface, pod *corev1.Pod) error

func Execute

func Execute(cmd string, args []string) error

func ExecuteWithRedirect

func ExecuteWithRedirect(cmd string, args []string, stdout io.Writer) error

func GetK8sclient

func GetK8sclient() (kubernetes.Interface, error)

func GetKernelVersion

func GetKernelVersion() string

GetKernelVersion return part of the result of 'uname -a' like '5.15.153.1-xxxx'

func GetMapByName

func GetMapByName(name string) (*ebpf.Map, error)

func GetProgramByName

func GetProgramByName(name string) (*ebpf.Program, error)

func HandleKmeshManage

func HandleKmeshManage(ns string, enroll bool) error

func Ifname2ifindex

func Ifname2ifindex(ifname string) (int, error)

func KernelVersionLowerThan5_13

func KernelVersionLowerThan5_13() bool

KernelVersionLowerThan5_13 return whether the current kernel version is lower than 5.13, and will fallback to less BPF log ability(return true) if error

func PatchKmeshRedirectAnnotation

func PatchKmeshRedirectAnnotation(client kubernetes.Interface, pod *corev1.Pod) error

func ShouldEnroll

func ShouldEnroll(pod *corev1.Pod, ns *corev1.Namespace) bool

ShouldEnroll checks whether a pod should be managed by kmesh. Kmesh manages a pod if a pod has "istio.io/dataplane-mode: kmesh" label or the namespace where it resides has the label while pod have no "istio.io/dataplane-mode: none" label Excluding cases: a pod has sidecar injected, or the pod is istio managed waypoint https://github.com/istio/istio/blob/33539491628fe5f3ad4f5f1fb339b0da9455c028/manifests/charts/istio-control/istio-discovery/files/waypoint.yaml#L35

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL