Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Healthchecking #117

Merged
merged 3 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
758 changes: 338 additions & 420 deletions Gopkg.lock

Large diffs are not rendered by default.

89 changes: 51 additions & 38 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,19 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true

# Force dep to vendor the code generators, which aren't imported just used at dev time.
required = [
"k8s.io/code-generator/cmd/defaulter-gen",
"k8s.io/code-generator/cmd/deepcopy-gen",
"k8s.io/code-generator/cmd/conversion-gen",
"k8s.io/code-generator/cmd/client-gen",
"k8s.io/code-generator/cmd/lister-gen",
"k8s.io/code-generator/cmd/informer-gen",
"k8s.io/code-generator/cmd/openapi-gen",
"k8s.io/gengo/args",
]

[[constraint]]
name = "github.com/ghodss/yaml"
version = "1.0.0"

[[override]]
name = "k8s.io/api"
version= "kubernetes-1.11.1"

[[override]]
name = "k8s.io/client-go"
version= "v6.0.0"

[[override]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.9.0"

[[override]]
name = "github.com/spf13/cobra"
version = "0.0.3"
Expand All @@ -61,6 +34,46 @@
name = "sigs.k8s.io/cluster-api"
branch = "master"

[[override]]
name = "k8s.io/code-generator"
# revision for tag "kubernetes-1.11.2"
revision = "6702109cc68eb6fe6350b83e14407c8d7309fd1a"

[[override]]
name = "k8s.io/api"
# revision for tag "kubernetes-1.11.2"
revision = "2d6f90ab1293a1fb871cf149423ebb72aa7423aa"

[[override]]
name = "k8s.io/apiextensions-apiserver"
# revision for tag "kubernetes-1.11.2"
revision = "408db4a50408e2149acbd657bceb2480c13cb0a4"

[[override]]
name = "k8s.io/apimachinery"
# revision for tag "kubernetes-1.11.2"
revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae"

[[override]]
name = "k8s.io/client-go"
# revision for tag "kubernetes-1.11.2"
revision = "1f13a808da65775f22cbf47862c4e5898d8f4ca1"

[[override]]
name = "sigs.k8s.io/controller-runtime"
version = "v0.1.4"

[[constraint]]
name = "github.com/operator-framework/operator-sdk"
# The version rule is used for a specific release and the master branch for in between releases.
branch = "master" #osdk_branch_annotation
# version = "=v0.1.1" #osdk_version_annotation

[prune]
go-tests = true
unused-packages = true
non-go = true

[[prune.project]]
name = "k8s.io/code-generator"
non-go = false
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ nodelink-controller:
@echo -e "\033[32mBuilding node link controller binary...\033[0m"
$(DOCKER_CMD) go build $(GOGCFLAGS) -o bin/nodelink-controller github.com/openshift/machine-api-operator/cmd/nodelink-controller

.PHONY: machine-healthcheck
machine-healthcheck:
@echo -e "\033[32mBuilding machine healthcheck binary...\033[0m"
$(DOCKER_CMD) go build $(GOGCFLAGS) -o bin/machine-healthcheck github.com/openshift/machine-api-operator/cmd/machine-healthcheck

.PHONY: build-e2e
build-e2e: ## Build end-to-end test binary
@echo -e "\033[32mBuilding e2e test binary...\033[0m"
Expand Down
57 changes: 57 additions & 0 deletions cmd/machine-healthcheck/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"flag"
"runtime"

"github.com/golang/glog"
"github.com/openshift/machine-api-operator/pkg/apis"
"github.com/openshift/machine-api-operator/pkg/controller"
sdkVersion "github.com/operator-framework/operator-sdk/version"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)

func printVersion() {
glog.Infof("Go Version: %s", runtime.Version())
glog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)
glog.Infof("operator-sdk Version: %v", sdkVersion.Version)
}

func main() {
flag.Parse()
printVersion()

// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if err != nil {
glog.Fatal(err)
}

// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{})
if err != nil {
glog.Fatal(err)
}

glog.Infof("Registering Components.")

// Setup Scheme for all resources
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
glog.Fatal(err)
}

// Setup all Controllers
if err := controller.AddToManager(mgr); err != nil {
glog.Fatal(err)
}

glog.Info("Starting the Cmd.")

// Start the Cmd
if err := mgr.Start(signals.SetupSignalHandler()); err != nil {
glog.Fatal(err)
}
}
10 changes: 10 additions & 0 deletions pkg/apis/addtoscheme_healthchecking_v1alpha1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package apis

import (
"github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
}
13 changes: 13 additions & 0 deletions pkg/apis/apis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package apis

import (
"k8s.io/apimachinery/pkg/runtime"
)

// AddToSchemes may be used to add all resources defined in the project to a Scheme
var AddToSchemes runtime.SchemeBuilder

// AddToScheme adds all Resources to the Scheme
func AddToScheme(s *runtime.Scheme) error {
return AddToSchemes.AddToScheme(s)
}
4 changes: 4 additions & 0 deletions pkg/apis/healthchecking/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Package v1alpha1 contains API Schema definitions for the healthchecking v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=healthchecking.openshift.io
package v1alpha1
40 changes: 40 additions & 0 deletions pkg/apis/healthchecking/v1alpha1/machinehealthcheck_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// MachineHealthCheckSpec defines the desired state of MachineHealthCheck
type MachineHealthCheckSpec struct {
Selector metav1.LabelSelector `json:"selector"`
}

// MachineHealthCheckStatus defines the observed state of MachineHealthCheck
type MachineHealthCheckStatus struct {
// TODO(alberto)
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// MachineHealthCheck is the Schema for the machinehealthchecks API
// +k8s:openapi-gen=true
type MachineHealthCheck struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MachineHealthCheckSpec `json:"spec,omitempty"`
Status MachineHealthCheckStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// MachineHealthCheckList contains a list of MachineHealthCheck
type MachineHealthCheckList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MachineHealthCheck `json:"items"`
}

func init() {
SchemeBuilder.Register(&MachineHealthCheck{}, &MachineHealthCheckList{})
}
19 changes: 19 additions & 0 deletions pkg/apis/healthchecking/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// NOTE: Boilerplate only. Ignore this file.

// Package v1alpha1 contains API Schema definitions for the healthchecking v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=healthchecking.openshift.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "healthchecking.openshift.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
)
119 changes: 119 additions & 0 deletions pkg/apis/healthchecking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/controller/add_machinehealthcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package controller

import (
"github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck"
)

func init() {
// AddToManagerFuncs is a list of functions to create controllers and add them to a manager.
AddToManagerFuncs = append(AddToManagerFuncs, machinehealthcheck.Add)
}
Loading