util

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 4 Imported by: 0

Documentation

Overview

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * 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 * * https://opensource.org/licenses/Apache-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 OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DeploymentPrefixKey  = "dp_"
	StatefulsetPrefixKey = "sts_"

	NoRefAppName       = "NULL"
	NoRefAppTypePrefix = "NULL_"
)

Variables

This section is empty.

Functions

func GetAppType

func GetAppType(appTypePrefix string) string

GetAppType formats appTypePrefix to appType

func GetAppTypePrefix

func GetAppTypePrefix(kind string) string

GetAppTypePrefix formats an appTypePrefix for the given resource kind

func Join

func Join(name, namespace string) string

func PodName

func PodName(pod *corev1.Pod) string

Types

type KeyObj

type KeyObj struct {
	// stores the key format in IPAM
	// for deployment dp_namespace_deploymentName_podName,
	// for pool pool__poolName_dp_namespace_deploymentName_podName, for statefulset
	// sts_namespace_statefulsetName_podName
	// If deployment name is 63 bytes, e.g. dp1234567890dp1234567890dp1234567890dp1234567890dp1234567890dp1
	// deployment pod name will be 63 bytes with modified suffix, e.g.
	// dp1234567890dp1234567890dp1234567890dp1234567890dp1234567848p74
	// So we can't get deployment name from pod name and have to store deployment name with pod name
	KeyInDB       string
	AppName       string
	AppTypePrefix string
	PodName       string
	Namespace     string
	// the annotation value if pod has pool annotation
	PoolName string
}

func FormatKey

func FormatKey(pod *corev1.Pod) (*KeyObj, error)

func NewKeyObj

func NewKeyObj(appTypePrefix string, namespace, appName, podName, poolName string) *KeyObj

func ParseKey

func ParseKey(key string) *KeyObj

func (*KeyObj) Deployment

func (k *KeyObj) Deployment() bool

func (*KeyObj) PoolAppPrefix

func (k *KeyObj) PoolAppPrefix() string

func (*KeyObj) PoolPrefix

func (k *KeyObj) PoolPrefix() string

PoolPrefix returns the common key prefix in IPAM, for deployment dp_namespace_deploymentName_ for pool pool__poolName_, for statefulset sts_namespace_statefulsetName_ For now, if it is a statefulset pod, PoolPrefix is useless since we reserve ip by full pod name PoolPrefix is used by pool and deployment only.

func (*KeyObj) StatefulSet

func (k *KeyObj) StatefulSet() bool

Jump to

Keyboard shortcuts

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