Commit d94a346a authored by Darren Shepherd's avatar Darren Shepherd

Switch to wrangler-api and helm-controller

parent c0702b04
apiVersion: k3s.cattle.io/v1
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: traefik
......
......@@ -4,7 +4,6 @@ import (
"github.com/rancher/dynamiclistener"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
)
// +genclient
......@@ -36,27 +35,3 @@ type AddonSpec struct {
type AddonStatus struct {
GVKs []schema.GroupVersionKind `json:"gvks,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type HelmChart struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec HelmChartSpec `json:"spec,omitempty"`
Status HelmChartStatus `json:"status,omitempty"`
}
type HelmChartSpec struct {
TargetNamespace string `json:"targetNamespace,omitempty"`
Chart string `json:"chart,omitempty"`
Version string `json:"version,omitempty"`
Repo string `json:"repo,omitempty"`
Set map[string]intstr.IntOrString `json:"set,omitempty"`
ValuesContent string `json:"valuesContent,omitempty"`
}
type HelmChartStatus struct {
JobName string `json:"jobName,omitempty"`
}
......@@ -8,10 +8,6 @@ import (
controllergen "github.com/rancher/wrangler/pkg/controller-gen"
"github.com/rancher/wrangler/pkg/controller-gen/args"
"github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
)
var (
......@@ -94,48 +90,9 @@ func main() {
Types: []interface{}{
v1.ListenerConfig{},
v1.Addon{},
v1.HelmChart{},
},
GenerateTypes: true,
},
"": {
Types: []interface{}{
corev1.ServiceAccount{},
corev1.Endpoints{},
corev1.Service{},
corev1.Pod{},
corev1.ConfigMap{},
corev1.Node{},
},
InformersPackage: "k8s.io/client-go/informers",
ClientSetPackage: "k8s.io/client-go/kubernetes",
ListersPackage: "k8s.io/client-go/listers",
},
"apps": {
Types: []interface{}{
appsv1.Deployment{},
appsv1.DaemonSet{},
},
InformersPackage: "k8s.io/client-go/informers",
ClientSetPackage: "k8s.io/client-go/kubernetes",
ListersPackage: "k8s.io/client-go/listers",
},
"batch": {
Types: []interface{}{
batchv1.Job{},
},
InformersPackage: "k8s.io/client-go/informers",
ClientSetPackage: "k8s.io/client-go/kubernetes",
ListersPackage: "k8s.io/client-go/listers",
},
"rbac": {
Types: []interface{}{
rbacv1.ClusterRoleBinding{},
},
InformersPackage: "k8s.io/client-go/informers",
ClientSetPackage: "k8s.io/client-go/kubernetes",
ListersPackage: "k8s.io/client-go/listers",
},
},
})
}
......@@ -31,8 +31,9 @@ const (
startKey = "_start_"
)
func WatchFiles(ctx context.Context, addons v1.AddonController, bases ...string) error {
func WatchFiles(ctx context.Context, apply apply.Apply, addons v1.AddonController, bases ...string) error {
w := &watcher{
apply: apply,
addonCache: addons.Cache(),
addons: addons,
bases: bases,
......
......@@ -5,7 +5,7 @@ import (
"strings"
"github.com/pkg/errors"
coreclient "github.com/rancher/k3s/pkg/generated/controllers/core/v1"
coreclient "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
"github.com/sirupsen/logrus"
core "k8s.io/api/core/v1"
)
......
......@@ -4,8 +4,8 @@ import (
"context"
"time"
coreClients "github.com/rancher/k3s/pkg/generated/controllers/core/v1"
"github.com/rancher/k3s/pkg/rootless"
coreClients "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
"github.com/rootless-containers/rootlesskit/pkg/api/client"
"github.com/rootless-containers/rootlesskit/pkg/port"
"github.com/sirupsen/logrus"
......
......@@ -3,9 +3,12 @@ package server
import (
"context"
"github.com/rancher/k3s/pkg/generated/controllers/apps"
"github.com/rancher/k3s/pkg/generated/controllers/core"
"github.com/rancher/helm-controller/pkg/generated/controllers/helm.cattle.io"
"github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io"
"github.com/rancher/wrangler-api/pkg/generated/controllers/apps"
"github.com/rancher/wrangler-api/pkg/generated/controllers/batch"
"github.com/rancher/wrangler-api/pkg/generated/controllers/core"
"github.com/rancher/wrangler-api/pkg/generated/controllers/rbac"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/crd"
"github.com/rancher/wrangler/pkg/start"
......@@ -16,14 +19,17 @@ import (
type Context struct {
K3s *k3s.Factory
Helm *helm.Factory
Batch *batch.Factory
Apps *apps.Factory
Auth *rbac.Factory
Core *core.Factory
K8s kubernetes.Interface
Apply apply.Apply
}
func (c *Context) Start(ctx context.Context) error {
return start.All(ctx, 5, c.K3s, c.Apps, c.Core)
return start.All(ctx, 5, c.K3s, c.Helm, c.Apps, c.Auth, c.Batch, c.Core)
}
func newContext(ctx context.Context, cfg string) (*Context, error) {
......@@ -39,8 +45,11 @@ func newContext(ctx context.Context, cfg string) (*Context, error) {
k8s := kubernetes.NewForConfigOrDie(restConfig)
return &Context{
K3s: k3s.NewFactoryFromConfigOrDie(restConfig),
Helm: helm.NewFactoryFromConfigOrDie(restConfig),
K8s: k8s,
Auth: rbac.NewFactoryFromConfigOrDie(restConfig),
Apps: apps.NewFactoryFromConfigOrDie(restConfig),
Batch: batch.NewFactoryFromConfigOrDie(restConfig),
Core: core.NewFactoryFromConfigOrDie(restConfig),
Apply: apply.New(k8s, apply.NewClientFactory(restConfig)),
}, nil
......@@ -55,7 +64,7 @@ func crds(ctx context.Context, config *rest.Config) error {
factory.BatchCreateCRDs(ctx, crd.NamespacedTypes(
"ListenerConfig.k3s.cattle.io/v1",
"Addon.k3s.cattle.io/v1",
"HelmChart.k3s.cattle.io/v1")...)
"HelmChart.helm.cattle.io/v1")...)
return factory.BatchWait()
}
......@@ -15,6 +15,7 @@ import (
"github.com/pkg/errors"
"github.com/rancher/dynamiclistener"
"github.com/rancher/helm-controller/pkg/helm"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/control"
......@@ -128,7 +129,11 @@ func masterControllers(ctx context.Context, sc *Context, config *Config) error {
return err
}
//helm.Register
helm.Register(ctx, sc.Apply,
sc.Helm.Helm().V1().HelmChart(),
sc.Batch.Batch().V1().Job(),
sc.Auth.Rbac().V1().ClusterRoleBinding(),
sc.Core.Core().V1().ServiceAccount())
if err := servicelb.Register(ctx,
sc.K8s,
......@@ -166,7 +171,7 @@ func stageFiles(ctx context.Context, sc *Context, controlConfig *config.Control)
return err
}
return deploy.WatchFiles(ctx, sc.K3s.K3s().V1().Addon(), dataDir)
return deploy.WatchFiles(ctx, sc.Apply, sc.K3s.K3s().V1().Addon(), dataDir)
}
func HomeKubeConfig(write, rootless bool) (string, error) {
......
......@@ -6,15 +6,13 @@ import (
"sort"
"strconv"
"github.com/rancher/wrangler/pkg/slice"
"github.com/rancher/wrangler/pkg/relatedresource"
appclient "github.com/rancher/k3s/pkg/generated/controllers/apps/v1"
coreclient "github.com/rancher/k3s/pkg/generated/controllers/core/v1"
appclient "github.com/rancher/wrangler-api/pkg/generated/controllers/apps/v1"
coreclient "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/condition"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/pkg/relatedresource"
"github.com/rancher/wrangler/pkg/slice"
"github.com/sirupsen/logrus"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment