Skip to content

Commit

Permalink
Initial set of pillar types related files
Browse files Browse the repository at this point in the history
- for cluster multi-node mode, some of the initial pillar side types
  related files, additional changes will be added in later PRs

Signed-off-by: Naiming Shen <naiming@zededa.com>
  • Loading branch information
naiming-zededa committed Oct 19, 2024
1 parent cc44ccf commit 316b999
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/pillar/types/cipherinfotypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ type EncryptionBlock struct {
CellularNetUsername string
CellularNetPassword string
ProtectedUserData string
ClusterToken string
}
56 changes: 56 additions & 0 deletions pkg/pillar/types/clustertypes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2024 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0

package types

import (
"net"

uuid "github.com/satori/go.uuid"
)

const (
ClusterStatusPort = "12346" // ClusterStatusPort - Port for k3s server for cluster status advertise
)

// EdgeNodeClusterConfig - Configuration for cluster multi-node from controller
type EdgeNodeClusterConfig struct {
ClusterName string
ClusterID UUIDandVersion
ClusterInterface string
ClusterIPPrefix *net.IPNet
IsWorkerNode bool
JoinServerIP net.IP
BootstrapNode bool

// CipherBlockStatus, for encrypted cluster token data
CipherToken CipherBlockStatus
}

// ENClusterAppStatus - Status of an App Instance in the multi-node cluster
type ENClusterAppStatus struct {
AppUUID uuid.UUID // UUID of the appinstance
IsDNSet bool // DesignatedNodeID is set for this node
ScheduledOnThisNode bool // App is running on this device
StatusRunning bool // Status of the app in "Running" state
IsVolumeDetached bool // Are volumes detached after failover ?
}

// Key - returns the key for the config of EdgeNodeClusterConfig
func (config EdgeNodeClusterConfig) Key() string {
return config.ClusterID.UUID.String()
}

// EdgeNodeClusterStatus - Status of the multi-node cluster published by zedkube
type EdgeNodeClusterStatus struct {
ClusterName string
ClusterID UUIDandVersion
ClusterInterface string
ClusterIPPrefix *net.IPNet
ClusterIPIsReady bool
IsWorkerNode bool
JoinServerIP net.IP
BootstrapNode bool

Error ErrorDescription
}
8 changes: 8 additions & 0 deletions pkg/pillar/types/domainmgrtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type DomainConfig struct {
// KubeImageName: is the container image reference we pass to domainmgr to launch a native container
// in kubevirt eve
KubeImageName string
// if this node is the DNiD of the App
IsDNidNode bool

// XXX: to be deprecated, use CipherBlockStatus instead
CloudInitUserData *string `json:"pubsub-large-CloudInitUserData"` // base64-encoded
Expand Down Expand Up @@ -321,6 +323,11 @@ type DomainStatus struct {
// FmlCustomResolution is the custom resolution for FML mode,
// xxx: this should be moved to VmConfig
FmlCustomResolution string
// if this node is the DNiD of the App
IsDNidNode bool
// the device name is used for kube node name
// Need to pass in from domainmgr to hypervisor context commands
NodeName string
}

func (status DomainStatus) Key() string {
Expand Down Expand Up @@ -474,6 +481,7 @@ type DomainMetric struct {
UsedMemoryPercent float64
LastHeard time.Time
Activated bool
NodeName string // kube app running on node
}

// Key returns the key for pubsub
Expand Down
82 changes: 82 additions & 0 deletions pkg/pillar/types/zedkubetypes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2024 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0

package types

import "time"

type KubeNodeStatus int8

Check failure on line 8 in pkg/pillar/types/zedkubetypes.go

View workflow job for this annotation

GitHub Actions / yetus

revive: exported type KubeNodeStatus should have comment or be unexported https://revive.run/r#exported

const (
KubeNodeStatusUnknown KubeNodeStatus = iota // KubeNodeStatusUnknown - Node status is unknown
KubeNodeStatusReady

Check failure on line 12 in pkg/pillar/types/zedkubetypes.go

View workflow job for this annotation

GitHub Actions / yetus

revive: exported const KubeNodeStatusReady should have comment (or a comment on this block) or be unexported https://revive.run/r#exported
KubeNodeStatusNotReady
KubeNodeStatusNotReachable
)

// KubeNodeInfo - Information about a Kubernetes node
type KubeNodeInfo struct {
Name string
Status KubeNodeStatus
IsMaster bool
IsEtcd bool
CreationTime time.Time
LastTransitionTime time.Time
KubeletVersion string
InternalIP string
ExternalIP string
Schedulable bool
}

// KubePodStatus - Enum for the status of a Kubernetes pod
type KubePodStatus int8

const (
KubePodStatusUnknown KubePodStatus = iota // KubePodStatusUnknown - Pod status is unknown
KubePodStatusPending // KubePodStatusPending - Pod is in pending status
KubePodStatusRunning // KubePodStatusRunning - Pod is in running status
KubePodStatusSucceeded // KubePodStatusSucceeded - Pod is in succeeded status
KubePodStatusFailed // KubePodStatusFailed - Pod is in failed status
)

// KubePodInfo - Information about a Kubernetes pod
type KubePodInfo struct {
Name string
Status KubePodStatus
RestartCount int32
RestartTimestamp time.Time
CreationTimestamp time.Time
PodIP string
NodeName string
}

// KubeVMIStatus - Enum for the status of a VirtualMachineInstance
type KubeVMIStatus int8

const (
KubeVMIStatusUnset KubeVMIStatus = iota // KubeVMIStatusUnset - UnSet VMI status
KubeVMIStatusPending // KubeVMIStatusPending - VMI in pending status
KubeVMIStatusScheduling // KubeVMIStatusScheduling - VMI in Scheduling status
KubeVMIStatusScheduled // KubeVMIStatusScheduled - VMI in Scheduled status
KubeVMIStatusRunning // KubeVMIStatusRunning - VMI in Running status
KubeVMIStatusSucceeded // KubeVMIStatusSucceeded - VMI in Succeeded status
KubeVMIStatusFailed // KubeVMIStatusFailed - VMI in Failed status
KubeVMIStatusUnknown // KubeVMIStatusUnknown - VMI in Unknown status
)

// KubeVMIInfo - Information about a VirtualMachineInstance
type KubeVMIInfo struct {
Name string
Status KubeVMIStatus
CreationTime time.Time
LastTransitionTime time.Time
IsReady bool
NodeName string
}

// KubeClusterInfo - Information about a Kubernetes cluster
type KubeClusterInfo struct {
Nodes []KubeNodeInfo // List of nodes in the cluster
AppPods []KubePodInfo // List of EVE application pods
AppVMIs []KubeVMIInfo // List of VirtualMachineInstance
}

0 comments on commit 316b999

Please sign in to comment.