Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to make the kata install daemon work with operator sdk 1.0
When we started work on the kata-operator we used the Operator SDK v0.16 which is now very outdated and discontinued. For this reason we decided to make the switch to SDK 1.0 and generate a new operator. This had effects on the daemon part as well. It is now using a dynamic kataconfig client. The part that installs the RPMs remains the same, we still use the kata-operator-payload image to download the RPMs and install them on the nodes host file system. All of this is imported from github.com/harche/kata-operator-daemon branch operator_sdk_upgrade_pr Signed-off-by: Harshal Patil <harpatil@redhat.com> Signed-off-by: Jens Freimann <jfreimann@redhat.com>
- Loading branch information
Showing
12 changed files
with
2,023 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
go build -o image/daemon cmd/daemon/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
kataDaemon "github.com/openshift/kata-operator-daemon/pkg/daemon" | ||
kataTypes "github.com/openshift/kata-operator/api/v1" | ||
mcfgapi "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||
nodeapi "k8s.io/kubernetes/pkg/apis/node/v1beta1" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func main() { | ||
|
||
var kataOperation string | ||
flag.StringVar(&kataOperation, "operation", "", "Specify kata operations. Valid options are 'install', 'upgrade', 'uninstall'") | ||
|
||
var kataConfigResourceName string | ||
flag.StringVar(&kataConfigResourceName, "resource", "", "Kata Config Custom Resource Name") | ||
flag.Parse() | ||
|
||
if kataOperation == "" { | ||
fmt.Println("Operation type must be specified. Check -h for more information.") | ||
os.Exit(1) | ||
} | ||
if kataConfigResourceName == "" { | ||
fmt.Println("Kata Custom Resource name must be specified. Check -h for more information.") | ||
os.Exit(1) | ||
} | ||
|
||
var kataActions kataDaemon.KataActions | ||
|
||
kataClient, err := getKataConfigClient() | ||
if err != nil { | ||
fmt.Printf("Unable to get dynamic kata config client, %+v", err) | ||
os.Exit(1) | ||
} | ||
|
||
kataActions = &kataDaemon.KataOpenShift{ | ||
KataClient: kataClient, | ||
} | ||
|
||
switch kataOperation { | ||
case "install": | ||
err := kataActions.Install(kataConfigResourceName) | ||
if err != nil { | ||
fmt.Printf("Error while installation: %+v", err) | ||
} | ||
case "upgrade": | ||
kataActions.Upgrade() | ||
case "uninstall": | ||
err := kataActions.Uninstall(kataConfigResourceName) | ||
if err != nil { | ||
fmt.Printf("Error while uninstallation: %+v", err) | ||
} | ||
default: | ||
fmt.Println("invalid operation. Check -h for more information.") | ||
} | ||
|
||
// Wait till controller kills us | ||
for { | ||
c := make(chan int) | ||
<-c | ||
} | ||
} | ||
|
||
func getKataConfigClient() (client.Client, error) { | ||
scheme := runtime.NewScheme() | ||
_ = clientgoscheme.AddToScheme(scheme) | ||
_ = kataTypes.AddToScheme(scheme) | ||
_ = nodeapi.AddToScheme(scheme) | ||
_ = mcfgapi.Install(scheme) | ||
|
||
kubeconfig := ctrl.GetConfigOrDie() | ||
kubeclient, err := client.New(kubeconfig, client.Options{Scheme: scheme}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return kubeclient, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module github.com/openshift/kata-operator-daemon | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/containers/image/v5 v5.5.1 | ||
github.com/coreos/go-semver v0.3.0 | ||
github.com/dsnet/compress v0.0.1 // indirect | ||
github.com/opencontainers/image-tools v1.0.0-rc1.0.20190306063041-93db3b16e673 | ||
github.com/openshift/client-go v0.0.0-20200827190008-3062137373b5 | ||
github.com/openshift/kata-operator v0.0.0-20201106123035-a3bf549cd866 | ||
github.com/openshift/machine-config-operator v0.0.1-0.20200918082730-c08c048584ef | ||
k8s.io/apimachinery v0.19.0 | ||
k8s.io/client-go v12.0.0+incompatible | ||
k8s.io/kubernetes v0.19.0 | ||
sigs.k8s.io/controller-runtime v0.6.3 | ||
) | ||
|
||
// Pinned to kubernetes-1.16.2 | ||
replace ( | ||
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.0.5 | ||
|
||
github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 // Required by Helm | ||
github.com/go-log/log => github.com/go-log/log v0.1.1-0.20181211034820-a514cf01a3eb | ||
github.com/openshift/api => github.com/openshift/api v0.0.0-20200916161728-83f0cb093902 | ||
|
||
// So that we can import MCO | ||
k8s.io/api => k8s.io/api v0.19.0 | ||
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.19.0 | ||
k8s.io/apimachinery => k8s.io/apimachinery v0.19.0 | ||
k8s.io/apiserver => k8s.io/apiserver v0.19.0 | ||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.19.0 | ||
k8s.io/client-go => k8s.io/client-go v0.19.0 | ||
k8s.io/cloud-provider => k8s.io/cloud-provider v0.19.0 | ||
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.19.0 | ||
k8s.io/code-generator => k8s.io/code-generator v0.19.0 | ||
k8s.io/component-base => k8s.io/component-base v0.19.0 | ||
k8s.io/cri-api => k8s.io/cri-api v0.19.0 | ||
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.19.0 | ||
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.19.0 | ||
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.19.0 | ||
k8s.io/kube-proxy => k8s.io/kube-proxy v0.19.0 | ||
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.19.0 | ||
k8s.io/kubectl => k8s.io/kubectl v0.19.0 | ||
k8s.io/kubelet => k8s.io/kubelet v0.19.0 | ||
k8s.io/kubernetes => k8s.io/kubernetes v1.19.0 | ||
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.19.0 | ||
k8s.io/metrics => k8s.io/metrics v0.19.0 | ||
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.19.0 | ||
) |
Oops, something went wrong.