Skip to content

Commit

Permalink
Add admin worker config
Browse files Browse the repository at this point in the history
  • Loading branch information
lmq1999 committed Sep 28, 2023
1 parent eadeeb3 commit b77d1d9
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test-coverage: ## Run tests with coverage
@cat cover.out >> coverage.txt

build: dep ## Build the binary file
@go build -i -o build/main *.go
@go build -o build/main *.go
## $(PKG)

clean: ## Remove previous build
Expand Down
Binary file added build/main
Binary file not shown.
3 changes: 3 additions & 0 deletions kubernetes_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
clusterPath = "/_"
kubeConfig = "kubeconfig"
k8sVersion = "/k8s_versions"
adminWorkerConfig = "/admin/worker_config"
)

var _ KubernetesEngineService = (*kubernetesEngineService)(nil)
Expand All @@ -23,6 +24,7 @@ type kubernetesEngineService struct {
client *Client
}


type KubernetesEngineService interface {
List(ctx context.Context, opts *ListOptions) ([]*Cluster, error)
Create(ctx context.Context, req *ClusterCreateRequest) (*ExtendedCluster, error)
Expand All @@ -36,6 +38,7 @@ type KubernetesEngineService interface {
DeleteClusterWorkerPoolNode(ctx context.Context, clusterUID string, PoolID string, NodeID string) error
GetKubeConfig(ctx context.Context, clusterUID string) (string, error)
GetKubernetesVersion(ctx context.Context) (*KubernetesVersionResponse, error)
GetAdminWorkerConfig(ctx context.Context) (*WorkerConfigs, error)
}

// KubernetesVersionResponse represents the get versions from the Kubernetes Engine API
Expand Down
40 changes: 40 additions & 0 deletions kubernetes_engine_admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package gobizfly

import (
"context"
"encoding/json"
"net/http"
)

type WorkerConfig struct {
ID string `json:"id" yaml:"id"`
Version string `json:"version" yaml:"version"`
Everywhere bool `json:"everywhere" yaml:"everywhere"`
Nvidiadevice bool `json:"nvidiadevice" yaml:"nvidiadevice"`
CniVersion string `json:"CNI_VERSION" yaml:"CNI_VERSION"`
RUNC_VERSION string `json:"RUNC_VERSION" yaml:"RUNC_VERSION"`
CONTAINERD_VERSION string `json:"CONTAINERD_VERSION" yaml:"CONTAINERD_VERSION"`
KUBE_VERSION string `json:"KUBE_VERSION" yaml:"KUBE_VERSION"`

}

type WorkerConfigs struct {
WorkerConfigs_ []WorkerConfig `json:"worker_configs" yaml:"worker_configs"`
}

func (c *kubernetesEngineService) GetAdminWorkerConfig(ctx context.Context) (*WorkerConfigs, error) {
var workerConfigs *WorkerConfigs
req, err := c.client.NewRequest(ctx, http.MethodGet, kubernetesServiceName, adminWorkerConfig, nil)
if err != nil {
return nil, err
}
resp, err := c.client.Do(ctx, req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := json.NewDecoder(resp.Body).Decode(workerConfigs); err != nil {
return nil, err
}
return workerConfigs, nil
}
1 change: 1 addition & 0 deletions kubernetes_engine_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Cluster struct {
CreatedAt string `json:"created_at" yaml:"created_at"`
CreatedBy string `json:"created_by" yaml:"created_by"`
WorkerPoolsCount int `json:"worker_pools_count" yaml:"worker_pools_count"`
ProvisionType string `json:"provision_type" yaml:"provision_type"`
}

// ExtendedCluster represents a Kubernetes cluster with additional worker pools' information
Expand Down
1 change: 1 addition & 0 deletions kubernetes_engine_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
// WorkerPool represents worker pool information
type WorkerPool struct {
Name string `json:"name" yaml:"name"`
ProvisionType string `json:"provision_type" yaml:"provision_type"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Flavor string `json:"flavor" yaml:"flavor"`
ProfileType string `json:"profile_type" yaml:"profile_type"`
Expand Down

0 comments on commit b77d1d9

Please sign in to comment.