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

Common api #37

Merged
merged 25 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions api/core/v1alpha1/core.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
syntax = "proto3";

package core.skv2.solo.io;

option go_package = "github.com/solo-io/skv2/pkg/api/core.skv2.solo.io/v1alpha1";

import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";

import "gogoproto/gogo.proto";
option (gogoproto.equal_all) = true;
import "extproto/ext.proto";
option (extproto.hash_all) = true;

// Resource reference for an object
message ObjectRef {

// (optional) api group of the resource being referenced
google.protobuf.StringValue api_group = 1;

// (optional) kind of the resource being referenced
google.protobuf.StringValue kind = 2;

// name of the resource being referenced
string name = 3;

// namespace of the resource being referenced
string namespace = 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comments)

}

// A generic status
message Status {

// The State of a reconciled object
enum State {
// Waiting to be processed.
PENDING = 0;

// Currently processing.
PROCESSING = 1;

// Invalid parameters supplied, will not continue.
INVALID = 2;

// Failed during processing.
FAILED = 3;

// Finished processing successfully.
ACCEPTED = 4;
}

// The current state of the resource
State state = 1;

// A human readable message about the current state of the object
string message = 2;

// The most recently observed generation of the resource. This value corresponds to the `metadata.generation` of
// a kubernetes resource
int64 observed_generation = 3;

// The time at which this status was recorded
google.protobuf.Timestamp processing_time = 4;

// (optional) The owner of the status, this value can be used to identify the entity which wrote this status.
// This is useful in situations where a given resource may have multiple owners.
google.protobuf.StringValue owner = 5;
}
58 changes: 58 additions & 0 deletions api/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have some code generation in skv2 for multicluster; maybe this belongs alongside that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have templates to generate multi cluster reconcilers, but I don't think we have code to specifically generate code in this repo to be consumed by other repos, I may be wrong though.


import (
"log"

"github.com/solo-io/skv2/codegen"
"github.com/solo-io/skv2/codegen/model"
"github.com/solo-io/solo-kit/pkg/code-generator/sk_anyvendor"
"k8s.io/apimachinery/pkg/runtime/schema"
)

//go:generate go run generate.go

func main() {
log.Println("starting kube client generation")

skv2Imports := sk_anyvendor.CreateDefaultMatchOptions([]string{
"api/**/*.proto",
})

skv2Cmd := codegen.Command{
Groups: []model.Group{
{
GroupVersion: schema.GroupVersion{
Group: "multicluster.solo.io",
Version: "v1alpha1",
},
Module: "github.com/solo-io/skv2",
Resources: []model.Resource{
{
Kind: "KubernetesCluster",
Spec: model.Field{
Type: model.Type{
Name: "KubernetesClusterSpec",
},
},
Status: &model.Field{
Type: model.Type{
Name: "KubernetesClusterStatus",
},
},
},
},
RenderManifests: true,
RenderController: true,
RenderProtos: true,
RenderClients: true,
RenderTypes: true,
ApiRoot: "pkg/api",
},
},
AnyVendorConfig: skv2Imports,
}
if err := skv2Cmd.Execute(); err != nil {
log.Fatal(err)
}
log.Printf("Finished generating kube clients\n")
}
39 changes: 39 additions & 0 deletions api/multicluster/v1alpha1/cluster.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";
package multicluster.solo.io;

import "gogoproto/gogo.proto";
option (gogoproto.equal_all) = true;
import "extproto/ext.proto";
option (extproto.hash_all) = true;

option go_package = "github.com/solo-io/skv2/pkg/api/multicluster.solo.io/v1alpha1";

import "skv2/api/core/v1alpha1/core.proto";

/*
Representation of a Kubernetes cluster that has been registered.
*/
message KubernetesClusterSpec {
// name of the secret which contains the kubeconfig with information to connect to the remote cluster.
core.skv2.solo.io.ObjectRef secret = 1;
}

message KubernetesClusterStatus {
// List of statuses about the kubernetes cluster.
// This list allows for multiple applications/pods to record their connection status.
repeated core.skv2.solo.io.Status status = 1;

// version of kubernetes
string version = 2;

// cloud provider, empty if unknown
string cloud = 3;

// Discovered information can be found here: https://kubernetes.io/docs/reference/kubernetes-api/labels-annotations-taints/
// Geographic location in which a kubernetes cluster resides
string region = 4;

// The specific zone within a region in which a the cluster resides
string zone = 5;

}
5 changes: 5 additions & 0 deletions changelog/v0.2.3/kubernetes-cluster-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/skv2/issues/15
resolvesIssue: false
description: Add kubernetes cluster resource to skv2, along with a couple smaller core API pieces.
23 changes: 23 additions & 0 deletions crds/multicluster.solo.io_v1alpha1_crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Code generated by skv2. DO NOT EDIT.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
labels:
app: ""
app.kubernetes.io/name: ""
name: kubernetesclusters.multicluster.solo.io
spec:
group: multicluster.solo.io
names:
kind: KubernetesCluster
listKind: KubernetesClusterList
plural: kubernetesclusters
singular: kubernetescluster
scope: Namespaced
subresources:
status: {}
versions:
- name: v1alpha1
served: true
storage: true
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/gophercloud/gophercloud v0.2.0 // indirect
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/hashstructure v1.0.0
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.8.1
github.com/pborman/uuid v1.2.0
Expand Down
Loading