kube

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 72 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameSpaceRegexString   = "[^a-z0-9.-]"
	DefaultNameRegexString = "^[a-zA-Z0-9-_]{1,50}$"
)
View Source
const (
	DefaultDindReplicas         int                          = 1
	DefaultDindLimitsCPU        int                          = 4000
	DefaultDindLimitsMemory     int                          = 8192
	DefaultDindStorageType      commonmodels.DindStorageType = commonmodels.DindStorageRootfs
	DefaultDindEnablePV         bool                         = false
	DefaultDindStorageClassName string                       = ""
	DefaultDindStorageSizeInGiB int                          = 10
)

Variables

View Source
var YamlTemplate = template.Must(template.New("agentYaml").Parse(`
---

apiVersion: v1
kind: Namespace
metadata:
  name: koderover-agent

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: koderover-agent
  namespace: koderover-agent

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: koderover-agent-admin-binding
  namespace: koderover-agent
subjects:
- kind: ServiceAccount
  name: koderover-agent
  namespace: koderover-agent
roleRef:
  kind: ClusterRole
  name: koderover-agent-admin
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: koderover-agent-admin
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '*'
  verbs:
  - '*'

---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: workflow-cm-manager
  namespace: koderover-agent
rules:
- apiGroups: [""]
  resources: ["configmaps"]
  verbs: ["*"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: workflow-cm-sa
  namespace: koderover-agent

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: workflow-cm-rolebinding
  namespace: koderover-agent
subjects:
- kind: ServiceAccount
  name: workflow-cm-sa
  namespace: koderover-agent
roleRef:
  kind: Role
  name: workflow-cm-manager
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: v1
kind: Service
metadata:
  name: hub-agent
  namespace: koderover-agent
  labels:
    app: koderover-agent-agent
spec:
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: koderover-agent-agent

---

apiVersion: apps/v1
{{- if .UseDeployment }}
kind: Deployment
{{- else }}
kind: DaemonSet
{{- end }}
metadata:
    name: koderover-agent-node-agent
    namespace: koderover-agent
spec:
  selector:
    matchLabels:
      app: koderover-agent-agent
  template:
    metadata:
      labels:
        app: koderover-agent-agent
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                - key: beta.kubernetes.io/os
                  operator: NotIn
                  values:
                    - windows
{{- if .UseDeployment }}
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              topologyKey: kubernetes.io/hostname
{{- end }}
      hostNetwork: true
      serviceAccountName: koderover-agent
      containers:
      - name: agent
        image: {{.HubAgentImage}}
        imagePullPolicy: Always
        env:
        - name: AGENT_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: HUB_AGENT_TOKEN
          value: "{{.ClientToken}}"
        - name: HUB_SERVER_BASE_ADDR
          value: "{{.HubServerBaseAddr}}"
        - name: ASLAN_BASE_ADDR
          value: "{{.AslanBaseAddr}}"
        resources:
          limits:
            cpu: 1000m
            memory: 1Gi
          requests:
            cpu: 100m
            memory: 256Mi
{{- if .UseDeployment }}
  replicas: 1
{{- else }}
  updateStrategy:
    type: RollingUpdate
{{- end }}

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: dind
  namespace: koderover-agent
  labels:
    app.kubernetes.io/component: dind
    app.kubernetes.io/name: zadig
spec:
  serviceName: dind
  replicas: {{.DindReplicas}}
  selector:
    matchLabels:
      app.kubernetes.io/component: dind
      app.kubernetes.io/name: zadig
  template:
    metadata:
      labels:
        app.kubernetes.io/component: dind
        app.kubernetes.io/name: zadig
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                topologyKey: kubernetes.io/hostname
      containers:
        - name: dind
          image: {{.DindImage}}
          env:
            - name: DOCKER_TLS_CERTDIR
              value: ""
          securityContext:
            privileged: true
          ports:
            - protocol: TCP
              containerPort: 2375
          resources:
            limits:
              cpu: {{.DindLimitsCPU}}
              memory: {{.DindLimitsMemory}}
            requests:
              cpu: 100m
              memory: 128Mi
{{- if .DindEnablePV }}
          volumeMounts:
          - name: zadig-docker
            mountPath: /var/lib/docker
  volumeClaimTemplates:
  - metadata:
      name: zadig-docker
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: {{.DindStorageClassName}}
      resources:
        requests:
          storage: {{.DindStorageSizeInGiB}}Gi
{{- end }}

---

apiVersion: v1
kind: Service
metadata:
  name: dind
  namespace: koderover-agent
  labels:
    app.kubernetes.io/component: dind
    app.kubernetes.io/name: zadig
spec:
  ports:
    - name: dind
      protocol: TCP
      port: 2375
      targetPort: 2375
  clusterIP: None
  selector:
    app.kubernetes.io/component: dind
    app.kubernetes.io/name: zadig
`))
View Source
var YamlTemplateForNamespace = template.Must(template.New("agentYaml").Parse(`
---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: koderover-agent-sa
  namespace: {{.Namespace}}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: koderover-agent-admin-binding
  namespace: {{.Namespace}}
subjects:
- kind: ServiceAccount
  name: koderover-agent-sa
  namespace: {{.Namespace}}
roleRef:
  kind: Role
  name: koderover-agent-admin-role
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: koderover-agent-admin-role
  namespace: {{.Namespace}}
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'

---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: workflow-cm-manager
  namespace: {{.Namespace}}
rules:
- apiGroups: [""]
  resources: ["configmaps"]
  verbs: ["*"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: workflow-cm-sa
  namespace: {{.Namespace}}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: workflow-cm-rolebinding
  namespace: {{.Namespace}}
subjects:
- kind: ServiceAccount
  name: workflow-cm-sa
  namespace: {{.Namespace}}
roleRef:
  kind: Role
  name: workflow-cm-manager
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: v1
kind: Service
metadata:
  name: hub-agent
  namespace: {{.Namespace}}
  labels:
    app: koderover-agent-agent
spec:
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: koderover-agent-agent

---

apiVersion: apps/v1
{{- if .UseDeployment }}
kind: Deployment
{{- else }}
kind: DaemonSet
{{- end }}
metadata:
    name: koderover-agent-node-agent
    namespace: {{.Namespace}}
spec:
  selector:
    matchLabels:
      app: koderover-agent-agent
  template:
    metadata:
      labels:
        app: koderover-agent-agent
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                - key: beta.kubernetes.io/os
                  operator: NotIn
                  values:
                    - windows
{{- if .UseDeployment }}
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              topologyKey: kubernetes.io/hostname
{{- end }}
      hostNetwork: true
      serviceAccountName: koderover-agent-sa
      containers:
      - name: agent
        image: {{.HubAgentImage}}
        imagePullPolicy: Always
        env:
        - name: AGENT_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: HUB_AGENT_TOKEN
          value: "{{.ClientToken}}"
        - name: HUB_SERVER_BASE_ADDR
          value: "{{.HubServerBaseAddr}}"
        - name: ASLAN_BASE_ADDR
          value: "{{.AslanBaseAddr}}"
        resources:
          limits:
            cpu: 1000m
            memory: 1Gi
          requests:
            cpu: 100m
            memory: 256Mi
{{- if .UseDeployment }}
  replicas: 1
{{- else }}
  updateStrategy:
    type: RollingUpdate
{{- end }}

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: dind
  namespace: {{.Namespace}}
  labels:
    app.kubernetes.io/component: dind
    app.kubernetes.io/name: zadig
spec:
  serviceName: dind
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/component: dind
      app.kubernetes.io/name: zadig
  template:
    metadata:
      labels:
        app.kubernetes.io/component: dind
        app.kubernetes.io/name: zadig
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                topologyKey: kubernetes.io/hostname
      containers:
        - name: dind
          image: {{.DindImage}}
          env:
            - name: DOCKER_TLS_CERTDIR
              value: ""
          securityContext:
            privileged: true
          ports:
            - protocol: TCP
              containerPort: 2375
          resources:
            limits:
              cpu: "4"
              memory: 8Gi
            requests:
              cpu: 100m
              memory: 128Mi
{{- if .DindEnablePV }}
          volumeMounts:
          - name: zadig-docker
            mountPath: /var/lib/docker
  volumeClaimTemplates:
  - metadata:
      name: zadig-docker
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: {{.DindStorageClassName}}
      resources:
        requests:
          storage: {{.DindStorageSizeInGiB}}Gi
{{- end }}

---

apiVersion: v1
kind: Service
metadata:
  name: dind
  namespace: {{.Namespace}}
  labels:
    app.kubernetes.io/component: dind
    app.kubernetes.io/name: zadig
spec:
  ports:
    - name: dind
      protocol: TCP
      port: 2375
      targetPort: 2375
  clusterIP: None
  selector:
    app.kubernetes.io/component: dind
    app.kubernetes.io/name: zadig
`))

Functions

func ApplySystemImagePullSecrets added in v1.9.9

func ApplySystemImagePullSecrets(podSpec *corev1.PodSpec)

func ApplyUpdatedAnnotations added in v1.9.9

func ApplyUpdatedAnnotations(annotations map[string]string) map[string]string

func CalculateContainer added in v1.9.9

func CalculateContainer(productSvc *commonmodels.ProductService, curUsedSvc *commonmodels.Service, latestContainers []*models.Container, productInfo *commonmodels.Product) []*models.Container

CalculateContainer calculates containers to be applied into environments for helm and k8s projects if image has no change since last deploy, containers in latest service will be used if image hse been change since lase deploy (eg. workflow), current values will be remained

func CreateNamespace

func CreateNamespace(namespace string, customLabels map[string]string, enableShare bool, kubeClient client.Client) error

func CreateOrPatchResource added in v1.9.9

func CreateOrPatchResource(applyParam *ResourceApplyParam, log *zap.SugaredLogger) ([]*unstructured.Unstructured, error)

CreateOrPatchResource create or patch resources defined in UpdateResourceYaml `CurrentResourceYaml` will be used to determine if some resources will be deleted

func CreateOrUpdateDefaultRegistrySecret added in v1.9.9

func CreateOrUpdateDefaultRegistrySecret(namespace string, reg *commonmodels.RegistryNamespace, kubeClient client.Client) error

func CreateOrUpdateRSASecret added in v1.9.9

func CreateOrUpdateRSASecret(publicKey, privateKey []byte, kubeClient client.Client) error

func CreateOrUpdateRegistrySecret

func CreateOrUpdateRegistrySecret(namespace string, reg *commonmodels.RegistryNamespace, isDefault bool, kubeClient client.Client) error

func DeleteHelmReleaseFromEnv added in v1.9.9

func DeleteHelmReleaseFromEnv(userName, requestID string, productInfo *commonmodels.Product, releaseNames []string, log *zap.SugaredLogger) error

1. Uninstall related resources 2. Delete service info from database

func DeleteHelmServiceFromEnv added in v1.9.9

func DeleteHelmServiceFromEnv(userName, requestID string, productInfo *commonmodels.Product, serviceNames []string, log *zap.SugaredLogger) error

DeleteHelmServiceFromEnv deletes the service from the environment 1. Uninstall related resources 2. Delete service info from database

func DeploymentSelectorLabelExists added in v1.9.9

func DeploymentSelectorLabelExists(resourceName, namespace string, informer informers.SharedInformerFactory, log *zap.SugaredLogger) bool

func EnsureDeleteK8sService added in v1.9.9

func EnsureDeleteK8sService(ctx context.Context, ns, svcName string, kclient client.Client, systemCreatedOnly bool) error

func EnsureDeletePreCreatedServices added in v1.9.9

func EnsureDeletePreCreatedServices(ctx context.Context, productName, namespace string, chartSpec *helmclient.ChartSpec, helmClient *helmtool.HelmClient) error

func EnsureDeleteZadigServiceByHelmRelease added in v1.9.9

func EnsureDeleteZadigServiceByHelmRelease(ctx context.Context, env *commonmodels.Product, releaseName string, helmClient helmclient.Client) error

func EnsureDeleteZadigServiceBySvcName added in v1.9.9

func EnsureDeleteZadigServiceBySvcName(ctx context.Context, env *commonmodels.Product, svcName string, kclient client.Client, istioClient versionedclient.Interface) error

func EnsureGrayEnvConfig added in v1.9.9

func EnsureGrayEnvConfig(ctx context.Context, env *commonmodels.Product, kclient client.Client, istioClient versionedclient.Interface) error

func EnsureNamespaceLabels added in v1.9.9

func EnsureNamespaceLabels(namespace string, customLabels map[string]string, kubeClient client.Client) error

func EnsureUpdateZadigService added in v1.9.9

func EnsureUpdateZadigService(ctx context.Context, env *commonmodels.Product, svcName string, kclient client.Client, istioClient versionedclient.Interface) error

func EnsureZadigServiceByManifest added in v1.9.9

func EnsureZadigServiceByManifest(ctx context.Context, productName, namespace, manifest string) error

func FetchCurrentAppliedYaml added in v1.9.9

func FetchCurrentAppliedYaml(option *GeneSvcYamlOption) (string, int, error)

FetchCurrentAppliedYaml generates full yaml of some service currently applied in Zadig and returns the service yaml, currently used service revision

func FetchSelectedWorkloads added in v1.9.9

func FetchSelectedWorkloads(namespace string, Resource []*WorkloadResource, kubeclient crClient.Client, clientSet *kubernetes.Clientset) ([]*appsv1.Deployment, []*appsv1.StatefulSet,
	[]*batchv1.CronJob, []*batchv1beta1.CronJob, error)

func GenRegistrySecretName added in v1.9.9

func GenRegistrySecretName(reg *commonmodels.RegistryNamespace) (string, error)

func GeneKVFromYaml added in v1.9.9

func GeneKVFromYaml(yamlContent string) ([]*commonmodels.VariableKV, error)

func GeneMergedValues added in v1.9.9

func GeneMergedValues(productSvc *commonmodels.ProductService, renderSet *commonmodels.RenderSet, images []string, fullValues bool) (string, error)

GeneMergedValues generate values.yaml used to install or upgrade helm chart, like param in after option -f If fullValues is set to true, full values yaml content will be returned, this case is used to preview values when running workflows

func GenerateYamlFromKV added in v1.9.9

func GenerateYamlFromKV(kvs []*commonmodels.VariableKV) (string, error)

func GetClientset

func GetClientset(clusterID string) (kubernetes.Interface, error)

GetClientset returns a client to interact with APIServer which implements kubernetes.Interface

func GetDirtyResources

func GetDirtyResources(ns string, kubeClient client.Client) []metav1.Object

GetDirtyResources searches for dirty active resources in the given namespace, and return their metadata.

func GetKubeAPIReader

func GetKubeAPIReader(clusterID string) (client.Reader, error)

func GetPredefinedClusterLabels added in v1.9.9

func GetPredefinedClusterLabels(product, service, envName string) map[string]string

func GetPredefinedLabels added in v1.9.9

func GetPredefinedLabels(product, service string) map[string]string

func GetRESTConfig

func GetRESTConfig(clusterID string) (*rest.Config, error)

func GetSelectedPodsInfo

func GetSelectedPodsInfo(selector labels.Selector, informer informers.SharedInformerFactory, log *zap.SugaredLogger) (string, string, []string)

func GetValidGVK added in v1.9.9

func GetValidGVK(gvk schema.GroupVersionKind, version *version.Info) schema.GroupVersionKind

in kubernetes 1.21+, CronJobV1BetaGVK is deprecated, so we should use CronJobGVK instead

func GetValidMatchData added in v1.18.0

func GetValidMatchData(spec *commonmodels.ImagePathSpec) map[string]string

func InitializeExternalCluster added in v1.9.9

func InitializeExternalCluster(hubserverAddr, clusterID string) error

InitializeExternalCluster initialized the resources in the cluster for zadig to run correctly. if the cluster is of type kubeconfig, we need to create following resource: Namespace: koderover-agent Service: dind StatefulSet: dind

func InstallOrUpgradeHelmChartWithValues added in v1.9.9

func InstallOrUpgradeHelmChartWithValues(param *ReleaseInstallParam, isRetry bool, helmClient *helmtool.HelmClient) error

func MakeSafeLabelValue

func MakeSafeLabelValue(value string) string

func MergeImages added in v1.9.9

func MergeImages(curContainers []*models.Container, images []string) []string

func MergeLabels

func MergeLabels(from, to map[string]string) map[string]string

func ParseSysKeys

func ParseSysKeys(namespace, envName, productName, serviceName, ori string) string

ParseSysKeys 渲染系统变量键值

func PrepareHelmServiceData added in v1.9.9

func RemoveClusterResources added in v1.9.9

func RemoveClusterResources(hubserverAddr, clusterID string) error

RemoveClusterResources Removes all the resources in the koderover-agent namespace along with the namespace itself

func RemoveHelmResource added in v1.9.9

func RemoveHelmResource(applyParam *ResourceApplyParam, log *zap.SugaredLogger) error

RemoveHelmResource create or patch helm services if service is not deployed ever, it will be added into target environment database will also be updated

func RenderEnvService added in v1.9.9

func RenderEnvService(prod *commonmodels.Product, render *commonmodels.RenderSet, service *commonmodels.ProductService) (yaml string, err error)

RenderEnvService renders service with particular revision and service vars in environment

func RenderServiceYaml added in v1.9.9

func RenderServiceYaml(originYaml, productName, serviceName string, rs *commonmodels.RenderSet) (string, error)

func SetFieldValueIsNotExist added in v1.9.9

func SetFieldValueIsNotExist(obj map[string]interface{}, value interface{}, fields ...string) map[string]interface{}

func StatefulsetSelectorLabelExists added in v1.9.9

func StatefulsetSelectorLabelExists(resourceName, namespace string, informer informers.SharedInformerFactory, log *zap.SugaredLogger) bool

func UninstallRelease added in v1.9.9

func UninstallRelease(helmClient helmclient.Client, env *commonmodels.Product, releaseName string, force bool) error

UninstallService uninstall release deployed by zadig

func UninstallService added in v1.9.9

func UninstallService(helmClient helmclient.Client, env *commonmodels.Product, revisionSvc *commonmodels.Service, force bool) error

UninstallService uninstall release deployed by zadig

func UninstallServiceByName added in v1.9.9

func UninstallServiceByName(helmClient helmclient.Client, serviceName string, env *commonmodels.Product, revision int64, force bool) error

func UpgradeHelmRelease added in v1.9.9

func UpgradeHelmRelease(product *commonmodels.Product, renderSet *commonmodels.RenderSet, productSvc *commonmodels.ProductService,
	svcTemp *commonmodels.Service, images []string, timeout int) error

UpgradeHelmRelease upgrades helm release with some specific images

Types

type EnvoyAddress added in v1.9.9

type EnvoyAddress struct {
	SocketAddress EnvoySocketAddress `json:"socket_address"`
}

type EnvoyClusterConfigLoadAssignment added in v1.9.9

type EnvoyClusterConfigLoadAssignment struct {
	ClusterName string             `json:"cluster_name"`
	Endpoints   []EnvoyLBEndpoints `json:"endpoints"`
}

type EnvoyEndpoint added in v1.9.9

type EnvoyEndpoint struct {
	Address EnvoyAddress `json:"address"`
}

type EnvoyEndpoints added in v1.9.9

type EnvoyEndpoints struct {
	Endpoint EnvoyEndpoint `json:"endpoint"`
}

type EnvoyLBEndpoints added in v1.9.9

type EnvoyLBEndpoints struct {
	LBEndpoints []EnvoyEndpoints `json:"lb_endpoints"`
}

type EnvoySocketAddress added in v1.9.9

type EnvoySocketAddress struct {
	Protocol  string `json:"protocol"`
	Address   string `json:"address"`
	PortValue int    `json:"port_value"`
}

type GeneSvcYamlOption added in v1.9.9

type GeneSvcYamlOption struct {
	ProductName           string
	EnvName               string
	ServiceName           string
	UpdateServiceRevision bool
	VariableYaml          string
	VariableKVs           []*commontypes.RenderVariableKV
	UnInstall             bool
	Containers            []*models.Container
}

type MatchedEnv added in v1.9.9

type MatchedEnv struct {
	EnvName   string
	Namespace string
}

type ReleaseInstallParam added in v1.9.9

type ReleaseInstallParam struct {
	ProductName    string
	Namespace      string
	ReleaseName    string
	MergedValues   string
	IsChartInstall bool
	RenderChart    *templatemodels.ServiceRender
	ServiceObj     *commonmodels.Service
	ProdService    *commonmodels.ProductService
	Timeout        int
	DryRun         bool
	Production     bool
}

type ResourceApplyParam added in v1.9.9

type ResourceApplyParam struct {
	ProductInfo         *commonmodels.Product
	ServiceName         string
	ServiceList         []string // used for batch operations
	CurrentResourceYaml string
	UpdateResourceYaml  string

	// used for helm services
	Images                []string // all images need to be updated, used for helm services
	VariableYaml          string   // variables
	Timeout               int      // timeout for helm services
	UpdateServiceRevision bool

	Informer         informers.SharedInformerFactory
	KubeClient       client.Client
	IstioClient      versionedclient.Interface
	AddZadigLabel    bool
	InjectSecrets    bool
	SharedEnvHandler SharedEnvHandler
	Uninstall        bool
}

type Service

type Service struct {
	*multicluster.Agent
	// contains filtered or unexported fields
}

func NewService

func NewService(hubServerAddr string) (*Service, error)

func (*Service) CreateCluster

func (s *Service) CreateCluster(cluster *models.K8SCluster, id string, logger *zap.SugaredLogger) (*models.K8SCluster, error)

func (*Service) DeleteCluster

func (s *Service) DeleteCluster(user string, id string, logger *zap.SugaredLogger) error

func (*Service) GetCluster

func (s *Service) GetCluster(id string, logger *zap.SugaredLogger) (*models.K8SCluster, error)

func (*Service) GetClusterByToken

func (s *Service) GetClusterByToken(token string, logger *zap.SugaredLogger) (*models.K8SCluster, error)

func (*Service) GetYaml

func (s *Service) GetYaml(id, agentImage, aslanURL, hubURI string, useDeployment bool, logger *zap.SugaredLogger) ([]byte, error)

func (*Service) ListClusters

func (s *Service) ListClusters(clusterType string, logger *zap.SugaredLogger) ([]*models.K8SCluster, error)

func (*Service) ListConnectedClusters

func (s *Service) ListConnectedClusters(logger *zap.SugaredLogger) ([]*models.K8SCluster, error)

func (*Service) UpdateCluster

func (s *Service) UpdateCluster(id string, cluster *models.K8SCluster, logger *zap.SugaredLogger) (*models.K8SCluster, error)

func (*Service) UpdateUpgradeAgentInfo added in v1.9.9

func (s *Service) UpdateUpgradeAgentInfo(id, updateHubagentErrorMsg string) error

type ShareEnvOp added in v1.9.9

type ShareEnvOp string
const (
	ShareEnvEnable  ShareEnvOp = "enable"
	ShareEnvDisable ShareEnvOp = "disable"
)

type ShareEnvReady added in v1.9.9

type ShareEnvReady struct {
	IsReady bool                `json:"is_ready"`
	Checks  ShareEnvReadyChecks `json:"checks"`
}

func (*ShareEnvReady) CheckAndSetReady added in v1.9.9

func (s *ShareEnvReady) CheckAndSetReady(state ShareEnvOp)

Note: `WorkloadsHaveK8sService` is an optional condition.

type ShareEnvReadyChecks added in v1.9.9

type ShareEnvReadyChecks struct {
	NamespaceHasIstioLabel  bool `json:"namespace_has_istio_label"`
	VirtualServicesDeployed bool `json:"virtualservice_deployed"`
	PodsHaveIstioProxy      bool `json:"pods_have_istio_proxy"`
	WorkloadsReady          bool `json:"workloads_ready"`
	WorkloadsHaveK8sService bool `json:"workloads_have_k8s_service"`
}

type SharedEnvHandler added in v1.9.9

type TemplateSchema

type TemplateSchema struct {
	HubAgentImage        string
	ClientToken          string
	HubServerBaseAddr    string
	Namespace            string
	UseDeployment        bool
	AslanBaseAddr        string
	DindReplicas         int
	DindLimitsCPU        string
	DindLimitsMemory     string
	DindImage            string
	DindEnablePV         bool
	DindStorageClassName string
	DindStorageSizeInGiB int
}

type WorkloadResource added in v1.9.9

type WorkloadResource struct {
	Type string
	Name string
}

func GenerateRenderedYaml added in v1.9.9

func GenerateRenderedYaml(option *GeneSvcYamlOption) (string, int, []*WorkloadResource, error)

GenerateRenderedYaml generates full yaml of some service defined in Zadig (images not included) and returns the service yaml, used service revision

func ReplaceWorkloadImages added in v1.9.9

func ReplaceWorkloadImages(rawYaml string, images []*commonmodels.Container) (string, []*WorkloadResource, error)

ReplaceWorkloadImages replace images in yaml with new images

Jump to

Keyboard shortcuts

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