Skip to content

Commit

Permalink
Merge pull request redhat-developer#5 from bf2fc6cc711aee1a0c2a/opera…
Browse files Browse the repository at this point in the history
…torv1
  • Loading branch information
wtrocki authored Nov 24, 2020
2 parents bbebb04 + 2d9adad commit 9ebbac5
Show file tree
Hide file tree
Showing 18 changed files with 499 additions and 16 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Go

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: make
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Running Operator:

1. Regenerate operator and resources
`make generate`
`make manifests`

2. Install operator

`make install`

3. Disable webhooks `make run ENABLE_WEBHOOKS=false`
see [operator-sdk documentation](https://sdk.operatorframework.io/docs/building-operators/golang/tutorial/) for further info

## Commands Used to Create Operator

Operator has muliple names embeeded that we need to clarify
Any rename will possibly mean changes in multiple places.
Renames on this project should be handled by recreating project completely.


> NOTE: Make sure you have latest version of the Operator-SDK CLI (used 1.2)
1. Init operator

operator-sdk init --domain=redhat.com --plugins=go.kubebuilder.io/v2 --project-name=oas-operator --repo=github.com/bf2fc6cc711aee1a0c2a/operator

2. Create API (without controller)
```
operator-sdk create api --version=v1 --group=oas --kind=ManagedKafkaConnection --namespaced=false --resource=true --controller=false
```

3. Add controller to your API if needed (later phase)

```
operator-sdk create api --version=v1 --group=oas --kind=ManagedKafkaConnection --namespaced=false --resource=false --controller=true
```
4 changes: 4 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ domain: redhat.com
layout: go.kubebuilder.io/v2
projectName: rhoas-operator
repo: github.com/bf2fc6cc711aee1a0c2a/operator
resources:
- group: oas
kind: ManagedKafkaConnection
version: v1
version: 3-alpha
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
# Managed Kafka Operator POC
# OpenShift Managed Application Services Operator (RHOAS)

## Running Operator:

1. Regenerate operator and resources
`make generate`
`make manifests`

2. Install operator

`make install`

3. Disable webhooks `make run ENABLE_WEBHOOKS=false`
see [operator-sdk documentation](https://sdk.operatorframework.io/docs/building-operators/golang/tutorial/) for further info
> Work in Progress: Kafka Operator POC
## Resources

### ManagedKafkaConnection
### ManagedKafkaConnection Example

```yaml
apiVersion: operators.coreos.com/v1alpha1
kind: ManagedKafkaConnection
metadata:
name: myKafkaConnection
name: projectKafkaConnection
spec:
bootstrapServer:
# This is the host name of the Kafka bootstrap
host: foo.bar.com
credentials:
# Right now we only support clientCredentials, but by specifying credentials kind we allow ourselves to specify
# other types in the future
kind: clientCredentials
kind: ClientCredentials
# The actual credential values
clientId:
# Values can appear in the custom resource
Expand All @@ -40,3 +29,7 @@ spec:
key: clientSecret
name: managedKafkaSecret
```
## Contributing
Check out the [Contributing Guide](./CONTRIBUTING.md) to learn more about the repository and how you can contribute.
20 changes: 20 additions & 0 deletions api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Package v1 contains API Schema definitions for the oas v1 API group
// +kubebuilder:object:generate=true
// +groupName=oas.redhat.com
package v1

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

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "oas.redhat.com", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
69 changes: 69 additions & 0 deletions api/v1/managedkafkaconnection_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package v1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ManagedKafkaConnectionSpec defines the desired state of ManagedKafkaConnection
type ManagedKafkaConnectionSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

BootstrapServer BootstrapServerSpec `json:"bootstrapServer"`
Credentials CredentialsSpec `json:"credentials"`
}

// BootstrapServerSpec contains server host information
type BootstrapServerSpec struct {
Host string `json:"host,omitempty"`
}

// CredentialType enumeration for types of credentails
type CredentialType string

const (
// ClientCredentials ... type
ClientCredentials CredentialType = "ClientCredentials"
)

// CredentialsSpec specification
type CredentialsSpec struct {
Kind CredentialType `json:"kind,omitempty"`
CientID string `json:"clientID,omitempty"`
ClientSecret string `json:"clientSecret,omitempty"`
}

// ManagedKafkaConnectionStatus defines the observed state of ManagedKafkaConnection
type ManagedKafkaConnectionStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster

// ManagedKafkaConnection is the Schema for the managedkafkaconnections API
type ManagedKafkaConnection struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ManagedKafkaConnectionSpec `json:"spec,omitempty"`
Status ManagedKafkaConnectionStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&ManagedKafkaConnection{}, &ManagedKafkaConnectionList{})
}
130 changes: 130 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 9ebbac5

Please sign in to comment.