runtime

package
v0.0.0-...-2e9186d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ClusterRole = "ClusterRole"
View Source
const ClusterRoleBinding = "ClusterRoleBinding"
View Source
const ExpireTime time.Duration = 24 * time.Hour
View Source
const KcpNamespace string = "kcp-system"
View Source
const Namespace = "kube-system"
View Source
const RUNTIME_ADMIN = "runtimeAdmin"
View Source
const RUNTIME_OPERATOR = "runtimeOperator"
View Source
const SA = "SA"
View Source
const ServiceAccount = "ServiceAccount"
View Source
const Token = "token"

Variables

View Source
var L2L3OperatorAggregationRule = map[string][]metav1.LabelSelector{
	RUNTIME_ADMIN: {
		{
			MatchLabels: map[string]string{
				"rbac.authorization.k8s.io/aggregate-to-admin": "true",
			},
		},
	},
	RUNTIME_OPERATOR: {
		{
			MatchLabels: map[string]string{
				"rbac.authorization.k8s.io/aggregate-to-edit": "true",
			},
		},
	},
}
View Source
var L2L3OperatorPolicyRule = map[string][]rbacv1.PolicyRule{
	RUNTIME_ADMIN: {
		rbacv1helpers.NewRule("*").Groups("*").Resources("*").RuleOrDie(),
		rbacv1helpers.NewRule("*").URLs("*").RuleOrDie(),
	},
	RUNTIME_OPERATOR: {
		rbacv1helpers.NewRule("*").Groups("*").Resources("pods/ephemeralcontainers").RuleOrDie(),
		rbacv1helpers.NewRule("get", "list", "watch").Groups("*").Resources("*").RuleOrDie(),
		rbacv1helpers.NewRule("get", "list", "watch").URLs("*").RuleOrDie(),
	},
}

Functions

func GetK8sClient

func GetK8sClient() (kubernetes.Interface, error)

func GetK8sConfig

func GetK8sConfig() (*restclient.Config, error)

func GetRawConfig

func GetRawConfig(runtimeID string) ([]byte, error)

func SetupConfigMap

func SetupConfigMap() error

Types

type JsonPatchType

type JsonPatchType struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	Value string `json:"value"`
}

type RollbackE

type RollbackE struct {
	Data []string
}

type RuntimeClient

type RuntimeClient struct {
	K8s               kubernetes.Interface
	KcpK8s            kubernetes.Interface
	User              SAInfo
	L2L3OperatiorRole string
	RollbackE         RollbackE
}

func NewRuntimeClient

func NewRuntimeClient(kubeConfig []byte, userID string, L2L3OperatiorRole string, tenant string) (*RuntimeClient, error)

func (*RuntimeClient) Cleaner

func (rtc *RuntimeClient) Cleaner() error

Clean service account and cluster role

func (*RuntimeClient) DeployConfigMap

func (rtc *RuntimeClient) DeployConfigMap(runtimeID string, L2L3OperatorRole string, startTime time.Time) error

func (*RuntimeClient) RetryDeleteClusterRoleBinding

func (rtc *RuntimeClient) RetryDeleteClusterRoleBinding(wg *sync.WaitGroup, errorCh chan error)

func (*RuntimeClient) RetryDeleteClusterRoles

func (rtc *RuntimeClient) RetryDeleteClusterRoles(wg *sync.WaitGroup, errorCh chan error)

func (*RuntimeClient) RetryDeleteServiceAccount

func (rtc *RuntimeClient) RetryDeleteServiceAccount(wg *sync.WaitGroup, errorCh chan error)

func (*RuntimeClient) Run

func (rtc *RuntimeClient) Run() (string, error)

kubeconfig access runtime, create sa and clusterrole and clusterrolebinding according to userID and l2L3OperatiorRole

func (*RuntimeClient) SetupTimer

func (rtc *RuntimeClient) SetupTimer(startTime time.Time, runtimeID string)

func (*RuntimeClient) UpdateConfigMap

func (rtc *RuntimeClient) UpdateConfigMap(runtimeID string) error

type SAInfo

type SAInfo struct {
	ServiceAccountName     string
	ClusterRoleName        string
	ClusterRoleAggrLabel   string
	ClusterRoleRulesName   string
	ClusterRoleBindingName string
	Namespace              string
	SecretName             string
	TenantID               string
}

Jump to

Keyboard shortcuts

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