Documentation
¶
Index ¶
- Constants
- Variables
- func AppendLeaseLabels(lid mtypes.LeaseID, labels map[string]string) map[string]string
- func LidNS(lid mtypes.LeaseID) string
- func ValidateSettings(settings Settings) error
- type ClusterDeployment
- func (d *ClusterDeployment) ClusterParams() crd.ClusterSettings
- func (d *ClusterDeployment) GetResourceVersion() string
- func (d *ClusterDeployment) LeaseID() mtypes.LeaseID
- func (d *ClusterDeployment) ManifestGroup() *mani.Group
- func (d *ClusterDeployment) SetResourceVersion(val string)
- func (d *ClusterDeployment) UpdateManifest() bool
- type ContextKey
- type Deployment
- type IClusterDeployment
- type IngressMode
- type Manifest
- type NS
- type NetPol
- type PermissionType
- type PolicyRuleGenerator
- type PolicyRuleRegistry
- type ResourcePolicyMapping
- type Role
- type RoleBinding
- type Service
- type ServiceAccount
- type ServiceCredentials
- type Settings
- type StatefulSet
- type Workload
- func (b *Workload) GetPermissions() []string
- func (b *Workload) GetWorkloadPermissions() *WorkloadPermissions
- func (b *Workload) HasPermissions() bool
- func (b *Workload) IsObjectRevisionLatest(labels map[string]string) bool
- func (b *Workload) NS() string
- func (b *Workload) Name() string
- func (b *Workload) Validate() error
- type WorkloadPermissions
Constants ¶
const ( AkashManagedLabelName = "akash.network" AkashManifestServiceLabelName = "akash.network/manifest-service" AkashNetworkStorageClasses = "akash.network/storageclasses" AkashServiceTarget = "akash.network/service-target" AkashServiceCapabilityGPU = "akash.network/capabilities.gpu" AkashServiceCapabilityStorage = "akash.network/capabilities.storage" AkashMetalLB = "metal-lb" AkashLeaseOwnerLabelName = "akash.network/lease.id.owner" AkashLeaseDSeqLabelName = "akash.network/lease.id.dseq" AkashLeaseGSeqLabelName = "akash.network/lease.id.gseq" AkashLeaseOSeqLabelName = "akash.network/lease.id.oseq" AkashLeaseProviderLabelName = "akash.network/lease.id.provider" AkashLeaseManifestVersion = "akash.network/manifest.version" AkashLeaseUpdatedAt = "akash.network/lease.updated_at" AkashManifestResourceVersion = "akash.network/manifest.resource.version" )
const ( ValTrue = "true" ValFalse = "false" )
const ( ResourceGPUNvidia = corev1.ResourceName("nvidia.com/gpu") ResourceGPUAMD = corev1.ResourceName("amd.com/gpu") GPUVendorNvidia = "nvidia" GPUVendorAMD = "amd" )
const SettingsKey = ContextKey("kube-client-settings")
const SuffixForNodePortServiceName = "-np"
Variables ¶
var ( ErrKubeBuilder = errors.New("kube-builder") ErrManifestServiceMismatch = errors.New("manifest service mismatch") ErrManifestRenameNotAllowed = errors.New("manifest service rename is not allowed") )
var ErrSettingsValidation = errors.New("settings validation")
Functions ¶
func AppendLeaseLabels ¶
func ValidateSettings ¶
Types ¶
type ClusterDeployment ¶
type ClusterDeployment struct {
Lid mtypes.LeaseID
Group *mani.Group
Sparams crd.ClusterSettings
// contains filtered or unexported fields
}
func (*ClusterDeployment) ClusterParams ¶
func (d *ClusterDeployment) ClusterParams() crd.ClusterSettings
func (*ClusterDeployment) GetResourceVersion ¶ added in v0.6.5
func (d *ClusterDeployment) GetResourceVersion() string
func (*ClusterDeployment) LeaseID ¶
func (d *ClusterDeployment) LeaseID() mtypes.LeaseID
func (*ClusterDeployment) ManifestGroup ¶
func (d *ClusterDeployment) ManifestGroup() *mani.Group
func (*ClusterDeployment) SetResourceVersion ¶ added in v0.6.5
func (d *ClusterDeployment) SetResourceVersion(val string)
func (*ClusterDeployment) UpdateManifest ¶
func (d *ClusterDeployment) UpdateManifest() bool
type ContextKey ¶
type ContextKey string
type Deployment ¶
type Deployment interface {
Create() (*appsv1.Deployment, error)
Update(obj *appsv1.Deployment) (*appsv1.Deployment, error)
// contains filtered or unexported methods
}
func NewDeployment ¶
func NewDeployment(workload *Workload) Deployment
type IClusterDeployment ¶
type IClusterDeployment interface {
LeaseID() mtypes.LeaseID
ManifestGroup() *mani.Group
UpdateManifest() bool
ClusterParams() crd.ClusterSettings
SetResourceVersion(string)
GetResourceVersion() string
}
func ClusterDeploymentFromDeployment ¶
func ClusterDeploymentFromDeployment(d ctypes.IDeployment) (IClusterDeployment, error)
type IngressMode ¶ added in v0.12.0
type IngressMode string
IngressMode represents the ingress mode for the cluster.
const ( IngressModeIngress IngressMode = "ingress" IngressModeGateway IngressMode = "gateway-api" )
func ParseIngressMode ¶ added in v0.12.0
func ParseIngressMode(s string) (IngressMode, error)
ParseIngressMode parses a string into an IngressMode, returning an error if the value is invalid.
type Manifest ¶
type Manifest interface {
Create() (*crd.Manifest, error)
Update(obj *crd.Manifest) (*crd.Manifest, error)
Name() string
// contains filtered or unexported methods
}
func BuildManifest ¶
type NS ¶
type NS interface {
Create() (*corev1.Namespace, error)
Update(obj *corev1.Namespace) (*corev1.Namespace, error)
// contains filtered or unexported methods
}
func BuildNS ¶
func BuildNS(settings Settings, deployment IClusterDeployment) NS
type NetPol ¶
type NetPol interface {
Create() ([]*netv1.NetworkPolicy, error)
Update(obj *netv1.NetworkPolicy) (*netv1.NetworkPolicy, error)
// contains filtered or unexported methods
}
func BuildNetPol ¶
func BuildNetPol(settings Settings, deployment IClusterDeployment) NetPol
type PermissionType ¶ added in v0.10.6
type PermissionType string
PermissionType represents the type of permission action (read, write, delete)
const (
PermissionTypeRead PermissionType = "read"
)
type PolicyRuleGenerator ¶ added in v0.10.6
type PolicyRuleGenerator func(resource string, permType PermissionType) []rbacv1.PolicyRule
PolicyRuleGenerator generates Kubernetes RBAC policy rules for a given resource
type PolicyRuleRegistry ¶ added in v0.10.6
type PolicyRuleRegistry struct {
// contains filtered or unexported fields
}
PolicyRuleRegistry holds all registered resource policy mappings
func NewPolicyRuleRegistry ¶ added in v0.10.6
func NewPolicyRuleRegistry() *PolicyRuleRegistry
NewPolicyRuleRegistry creates a new registry with default resource mappings
func (*PolicyRuleRegistry) GenerateRules ¶ added in v0.10.6
func (r *PolicyRuleRegistry) GenerateRules(permissions *WorkloadPermissions) []rbacv1.PolicyRule
GenerateRules generates all policy rules for the given permissions
func (*PolicyRuleRegistry) Register ¶ added in v0.10.6
func (r *PolicyRuleRegistry) Register(mapping ResourcePolicyMapping)
Register adds a new resource policy mapping to the registry
type ResourcePolicyMapping ¶ added in v0.10.6
type ResourcePolicyMapping struct {
// Name is the resource identifier (e.g., "logs", "events")
Name string
// Generator creates the policy rules for this resource based on permission type
Generator PolicyRuleGenerator
}
ResourcePolicyMapping defines the policy rules for a specific resource type. This allows easy extension when new resources need to be supported.
type Role ¶ added in v0.10.6
type Role interface {
Create() (*rbacv1.Role, error)
Update(obj *rbacv1.Role) (*rbacv1.Role, error)
// contains filtered or unexported methods
}
func BuildRole ¶ added in v0.10.6
BuildRole creates a new Role builder for the given workload. It uses the default PolicyRuleRegistry which includes mappings for all supported resource types (logs, events, etc.).
func BuildRoleWithRegistry ¶ added in v0.10.6
func BuildRoleWithRegistry(workload *Workload, registry *PolicyRuleRegistry) Role
BuildRoleWithRegistry creates a new Role builder with a custom PolicyRuleRegistry. This is useful for testing or for cases where custom resource mappings are needed.
type RoleBinding ¶ added in v0.10.6
type RoleBinding interface {
Create() (*rbacv1.RoleBinding, error)
Update(obj *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
// contains filtered or unexported methods
}
RoleBinding is a builder for creating or updating a Kubernetes RoleBinding.
The builder always creates RoleBindings with:
- RoleRef pointing to a Role of the same name in the same namespace
- A single Subject referencing a ServiceAccount of the same name in the same namespace
Note: Kubernetes does not allow updating RoleRef on an existing RoleBinding. If the RoleRef needs to change, the RoleBinding must be deleted and recreated.
func BuildRoleBinding ¶ added in v0.10.6
func BuildRoleBinding(workload *Workload) RoleBinding
BuildRoleBinding creates a new RoleBinding builder for the given workload.
type Service ¶
type Service interface {
Create() (*corev1.Service, error)
Update(obj *corev1.Service) (*corev1.Service, error)
Any() bool
// contains filtered or unexported methods
}
func BuildService ¶
type ServiceAccount ¶ added in v0.10.6
type ServiceAccount interface {
Create() (*corev1.ServiceAccount, error)
Update(obj *corev1.ServiceAccount) (*corev1.ServiceAccount, error)
// contains filtered or unexported methods
}
func BuildServiceAccount ¶ added in v0.10.6
func BuildServiceAccount(workload *Workload) ServiceAccount
type ServiceCredentials ¶
type ServiceCredentials interface {
Create() (*corev1.Secret, error)
Update(obj *corev1.Secret) (*corev1.Secret, error)
// contains filtered or unexported methods
}
func NewServiceCredentials ¶
func NewServiceCredentials(workload *Workload, credentials *mani.ImageCredentials) ServiceCredentials
type Settings ¶
type Settings struct {
// gcp: NodePort
// others: ClusterIP
DeploymentServiceType corev1.ServiceType
// gcp: false
// others: true
DeploymentIngressStaticHosts bool
// Ingress domain to map deployments to
DeploymentIngressDomain string
// Return load balancer host in lease status command ?
// gcp: true
// others: optional
DeploymentIngressExposeLBHosts bool
// Global hostname for arbitrary ports
ClusterPublicHostname string
// NetworkPoliciesEnabled determines if NetworkPolicies should be installed.
NetworkPoliciesEnabled bool
// APIServerEndpoints are the addresses of all Kubernetes API server backends
// (from the "kubernetes" endpoints in the default namespace, not the ClusterIP).
// HA control planes have multiple backends; all must be allowed in network
// policies because CNIs like Calico evaluate egress rules after DNAT.
APIServerEndpoints []net.TCPAddr
CPUCommitLevel float64
GPUCommitLevel float64
MemoryCommitLevel float64
StorageCommitLevel float64
DeploymentRuntimeClass string
// Name of the image pull secret to use in pod spec
DockerImagePullSecretsName string
// Ingress mode: "ingress" or "gateway-api"
IngressMode IngressMode
// Gateway name when using gateway-api mode
GatewayName string
// Gateway namespace when using gateway-api mode
GatewayNamespace string
// Gateway provider when using gateway-api mode
GatewayProvider string
}
Settings configures k8s object generation such that it is customized to the cluster environment that is being used. For instance, GCP requires a different service type than minikube.
func NewDefaultSettings ¶
func NewDefaultSettings() Settings
type StatefulSet ¶
type StatefulSet interface {
Create() (*appsv1.StatefulSet, error)
Update(obj *appsv1.StatefulSet) (*appsv1.StatefulSet, error)
// contains filtered or unexported methods
}
func BuildStatefulSet ¶
func BuildStatefulSet(workload *Workload) StatefulSet
type Workload ¶
type Workload struct {
// contains filtered or unexported fields
}
func NewWorkloadBuilder ¶
func (*Workload) GetPermissions ¶ added in v0.10.6
GetPermissions returns the read permissions list for backward compatibility. Deprecated: Use GetWorkloadPermissions() for access to all permission types.
func (*Workload) GetWorkloadPermissions ¶ added in v0.10.6
func (b *Workload) GetWorkloadPermissions() *WorkloadPermissions
GetWorkloadPermissions returns all permissions for this workload organized by type.
func (*Workload) HasPermissions ¶ added in v0.10.6
HasPermissions returns true if any permissions are defined for this workload.
func (*Workload) IsObjectRevisionLatest ¶ added in v0.6.5
type WorkloadPermissions ¶ added in v0.10.6
type WorkloadPermissions struct {
Read []string
}
WorkloadPermissions holds permissions organized by type for a workload. This structure supports Read permissions.
func (*WorkloadPermissions) GetByType ¶ added in v0.10.6
func (p *WorkloadPermissions) GetByType(permType PermissionType) []string
GetByType returns the permissions for a given type
func (*WorkloadPermissions) HasAny ¶ added in v0.10.6
func (p *WorkloadPermissions) HasAny() bool
HasAny returns true if any permissions are defined
func (*WorkloadPermissions) HasRead ¶ added in v0.10.6
func (p *WorkloadPermissions) HasRead() bool
HasRead returns true if any read permissions are defined