Skip to content

Commit

Permalink
Upgrade microcluster to v3 (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 authored Aug 28, 2024
1 parent 545d1fb commit 6d8b29d
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 102 deletions.
39 changes: 17 additions & 22 deletions src/k8s/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ require (
dario.cat/mergo v1.0.0
github.com/canonical/go-dqlite v1.22.0
github.com/canonical/k8s-snap-api v1.0.3
github.com/canonical/lxd v0.0.0-20240730172021-8e39e5d4f55f
github.com/canonical/microcluster/v2 v2.0.2
github.com/canonical/lxd v0.0.0-20240822122218-e7b2a7a83230
github.com/canonical/microcluster/v3 v3.0.0-20240827143335-f7a4d3984970
github.com/go-logr/logr v1.4.2
github.com/mitchellh/mapstructure v1.5.0
github.com/moby/sys/mountinfo v0.7.1
github.com/onsi/gomega v1.32.0
github.com/pelletier/go-toml v1.9.5
github.com/spf13/cobra v1.8.1
golang.org/x/net v0.27.0
golang.org/x/sync v0.7.0
golang.org/x/sys v0.22.0
golang.org/x/net v0.28.0
golang.org/x/sync v0.8.0
golang.org/x/sys v0.24.0
gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.15.3
k8s.io/api v0.30.1
Expand All @@ -28,11 +28,6 @@ require (
sigs.k8s.io/controller-runtime v0.18.4
)

// We are switching to the microcluster fork temporarily which removes the join name verification to unblock CAPI work.
// This will be reverted once a proper solution that addresses CAPI requirements is merged upstream.
// https://github.com/canonical/microcluster/issues/234
replace github.com/canonical/microcluster/v2 v2.0.2 => github.com/canonical/k8s-microcluster/v2 v2.1.0

require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
Expand Down Expand Up @@ -131,39 +126,39 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.6 // indirect
github.com/pkg/xattr v0.4.10 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_golang v1.20.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.54.0 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rubenv/sql-migrate v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/zitadel/logging v0.6.0 // indirect
github.com/zitadel/oidc/v3 v3.26.0 // indirect
github.com/zitadel/oidc/v3 v3.27.0 // indirect
github.com/zitadel/schema v1.3.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.starlark.net v0.0.0-20240520160348-046347dcd104 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
go.starlark.net v0.0.0-20240725214946-42030a7cedce // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
82 changes: 42 additions & 40 deletions src/k8s/go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/k8s/pkg/client/k8sd/k8sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package k8sd
import (
"fmt"

"github.com/canonical/microcluster/v2/client"
"github.com/canonical/microcluster/v2/microcluster"
"github.com/canonical/microcluster/v3/client"
"github.com/canonical/microcluster/v3/microcluster"
)

// k8sd implements Client.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/capi_access_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/canonical/k8s/pkg/k8sd/database"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func ValidateCAPIAuthTokenAccessHandler(tokenHeaderName string) func(s state.State, r *http.Request) (bool, response.Response) {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/capi_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
apiv1 "github.com/canonical/k8s-snap-api/api/v1"
"github.com/canonical/k8s/pkg/k8sd/database"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postSetClusterAPIAuthToken(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/certificates_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/canonical/k8s/pkg/utils"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
"golang.org/x/sync/errgroup"
certv1 "k8s.io/api/certificates/v1"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/features"
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) getClusterStatus(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/cluster_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
apiv1 "github.com/canonical/k8s-snap-api/api/v1"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postClusterBootstrap(_ state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) putClusterConfig(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/cluster_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postClusterJoin(s state.State, r *http.Request) response.Response {
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/api/cluster_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/canonical/k8s/pkg/utils/control"
nodeutil "github.com/canonical/k8s/pkg/utils/node"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/cluster"
"github.com/canonical/microcluster/v3/state"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/api/cluster_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/microcluster"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/microcluster"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postClusterJoinTokens(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"

apiv1 "github.com/canonical/k8s-snap-api/api/v1"
"github.com/canonical/microcluster/v2/rest"
"github.com/canonical/microcluster/v3/rest"
)

type Endpoints struct {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/impl/k8sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/canonical/k8s/pkg/snap"
snaputil "github.com/canonical/k8s/pkg/snap/util"
nodeutil "github.com/canonical/k8s/pkg/utils/node"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

// GetClusterMembers retrieves information about the members of the cluster.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/setup"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) getKubeconfig(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/kubernetes_auth_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
databaseutil "github.com/canonical/k8s/pkg/k8sd/database/util"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postKubernetesAuthTokens(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
apiv1 "github.com/canonical/k8s-snap-api/api/v1"
"github.com/canonical/k8s/pkg/k8sd/api/impl"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) getNodeStatus(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package api

import (
"github.com/canonical/k8s/pkg/snap"
"github.com/canonical/microcluster/v2/microcluster"
"github.com/canonical/microcluster/v3/microcluster"
)

// Provider is an interface for state that the API endpoints need access to.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/pki"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postWorkerInfo(s state.State, r *http.Request) response.Response {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/worker_access_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
snaputil "github.com/canonical/k8s/pkg/snap/util"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) restrictWorkers(s state.State, r *http.Request) (bool, response.Response) {
Expand Down
6 changes: 3 additions & 3 deletions src/k8s/pkg/k8sd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"github.com/canonical/k8s/pkg/log"
"github.com/canonical/k8s/pkg/snap"
"github.com/canonical/k8s/pkg/utils/control"
"github.com/canonical/microcluster/v2/client"
"github.com/canonical/microcluster/v2/microcluster"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/client"
"github.com/canonical/microcluster/v3/microcluster"
"github.com/canonical/microcluster/v3/state"
)

// Config defines configuration for the k8sd app.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/app/hooks_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
snaputil "github.com/canonical/k8s/pkg/snap/util"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/k8s/pkg/utils/experimental/snapdconfig"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

// onBootstrap is called after we bootstrap the first cluster node.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/app/hooks_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/setup"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/k8s/pkg/utils/experimental/snapdconfig"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

// onPostJoin is called when a control plane node joins the cluster.
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/app/hooks_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/canonical/k8s/pkg/log"
snaputil "github.com/canonical/k8s/pkg/snap/util"
"github.com/canonical/k8s/pkg/utils/control"
"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/cluster"
"github.com/canonical/microcluster/v3/state"
)

// NOTE(ben): the pre-remove performs a series of cleanup steps on a best-effort basis.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/app/hooks_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/canonical/k8s/pkg/log"
"github.com/canonical/k8s/pkg/utils"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

func (a *App) onStart(ctx context.Context, s state.State) error {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/app/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/canonical/k8s/pkg/k8sd/api"
"github.com/canonical/k8s/pkg/snap"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/microcluster/v2/microcluster"
"github.com/canonical/microcluster/v3/microcluster"
)

func (a *App) MicroCluster() *microcluster.MicroCluster {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/capi_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"database/sql"
"fmt"

"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v3/cluster"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"

"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v3/cluster"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/feature_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/log"
"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v3/cluster"
)

var featureStatusStmts = map[string]int{
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/kubernetes_auth_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"sort"
"strings"

"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v3/cluster"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"

"github.com/canonical/lxd/lxd/db/schema"
"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v3/cluster"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/canonical/k8s/pkg/k8sd/database"
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

// GetClusterConfig is a convenience wrapper around the database call to get the cluster config.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/util/kubernetes_auth_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"github.com/canonical/k8s/pkg/k8sd/database"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

// GetOrCreateAuthToken returns a k8s auth token based on the provided username/groups.
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/canonical/k8s/pkg/k8sd/app"
"github.com/canonical/microcluster/v2/state"
"github.com/canonical/microcluster/v3/state"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"time"

"github.com/canonical/microcluster/v2/cluster"
"github.com/canonical/microcluster/v3/cluster"
)

var (
Expand Down
Loading

0 comments on commit 6d8b29d

Please sign in to comment.