utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 28 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotationEnabled added in v1.0.0

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 DelKmeshRedirectAnnotation added in v0.5.0

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 GetKernelVersion added in v0.5.0

func GetKernelVersion() string

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

func GetMapByName added in v0.3.0

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

func GetProgramByName added in v0.3.0

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

func GetVethPeerIndexFromInterface added in v1.0.0

func GetVethPeerIndexFromInterface(iface net.Interface) (uint64, error)

func GetVethPeerIndexFromName added in v1.0.0

func GetVethPeerIndexFromName(ifaceName string) (uint64, error)

func HandleKmeshManage added in v0.5.0

func HandleKmeshManage(ns string, enroll bool) error

func IfaceContainIPs added in v1.0.0

func IfaceContainIPs(iface net.Interface, IPs []string) (bool, error)

func KernelVersionLowerThan5_13 added in v0.5.0

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 ManageTCProgram added in v1.0.0

func ManageTCProgram(link netlink.Link, tc *ebpf.Program, mode int) error

func ManageTCProgramByFd added in v1.0.0

func ManageTCProgramByFd(link netlink.Link, tcFd int, mode int) error

func PatchKmeshRedirectAnnotation added in v0.5.0

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

func ShouldEnroll added in v0.5.0

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

type HashName added in v1.0.0

type HashName struct {
	// contains filtered or unexported fields
}

HashName converts a string to a uint32 integer as the key of bpf map

func NewHashName added in v1.0.0

func NewHashName() *HashName

func (*HashName) Delete added in v1.0.0

func (h *HashName) Delete(str string)

func (*HashName) GetStrToNum added in v1.0.0

func (h *HashName) GetStrToNum() map[string]uint32

func (*HashName) Hash added in v1.0.0

func (h *HashName) Hash(str string) uint32

func (*HashName) NumToStr added in v1.0.0

func (h *HashName) NumToStr(num uint32) string

func (*HashName) Reset added in v1.0.0

func (h *HashName) Reset()

Should only be used by test

func (*HashName) StrToNum added in v1.0.0

func (h *HashName) StrToNum(str string) uint32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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