Skip to content

Commit dd89da0

Browse files
author
orannahoum
committed
Skydiveanalyzer reconciler creats Deployment, service, and routes for both old and new UI.
Skydiveagnets reconciler creates DaemonSet (pods are stuck in pending) Added README.md.
1 parent b5e6218 commit dd89da0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2419
-0
lines changed

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build the manager binary
2+
FROM golang:1.13 as builder
3+
4+
WORKDIR /workspace
5+
# Copy the Go Modules manifests
6+
COPY go.mod go.mod
7+
COPY go.sum go.sum
8+
# cache deps before building and copying source so that we don't need to re-download as much
9+
# and so that source changes don't invalidate our downloaded layer
10+
RUN go mod download
11+
12+
# Copy the go source
13+
COPY main.go main.go
14+
COPY api/ api/
15+
COPY controllers/ controllers/
16+
17+
# Build
18+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
19+
20+
# Use distroless as minimal base image to package the manager binary
21+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
22+
FROM gcr.io/distroless/static:nonroot
23+
WORKDIR /
24+
COPY --from=builder /workspace/manager .
25+
USER nonroot:nonroot
26+
27+
ENTRYPOINT ["/manager"]

Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
# Image URL to use all building/pushing image targets
3+
IMG ?= controller:latest
4+
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
5+
CRD_OPTIONS ?= "crd:crdVersions=v1"
6+
7+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8+
ifeq (,$(shell go env GOBIN))
9+
GOBIN=$(shell go env GOPATH)/bin
10+
else
11+
GOBIN=$(shell go env GOBIN)
12+
endif
13+
14+
all: manager
15+
16+
# Run tests
17+
test: generate fmt vet manifests
18+
go test ./... -coverprofile cover.out
19+
20+
# Build manager binary
21+
manager: generate fmt vet
22+
go build -o bin/manager main.go
23+
24+
# Run against the configured Kubernetes cluster in ~/.kube/config
25+
run: generate fmt vet manifests
26+
go run ./main.go
27+
28+
# Install CRDs into a cluster
29+
install: manifests
30+
kustomize build config/crd | kubectl apply -f -
31+
32+
# Uninstall CRDs from a cluster
33+
uninstall: manifests
34+
kustomize build config/crd | kubectl delete -f -
35+
36+
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
37+
deploy: manifests
38+
cd config/manager && kustomize edit set image controller=${IMG}
39+
kustomize build config/default | kubectl apply -f -
40+
41+
# Generate manifests e.g. CRD, RBAC etc.
42+
manifests: controller-gen
43+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
44+
45+
# Run go fmt against code
46+
fmt:
47+
go fmt ./...
48+
49+
# Run go vet against code
50+
vet:
51+
go vet ./...
52+
53+
# Generate code
54+
generate: controller-gen
55+
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
56+
57+
# Build the docker image
58+
docker-build: test
59+
docker build . -t ${IMG}
60+
61+
# Push the docker image
62+
docker-push:
63+
docker push ${IMG}
64+
65+
# find or download controller-gen
66+
# download controller-gen if necessary
67+
controller-gen:
68+
ifeq (, $(shell which controller-gen))
69+
@{ \
70+
set -e ;\
71+
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
72+
cd $$CONTROLLER_GEN_TMP_DIR ;\
73+
go mod init tmp ;\
74+
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
75+
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
76+
}
77+
CONTROLLER_GEN=$(GOBIN)/controller-gen
78+
else
79+
CONTROLLER_GEN=$(shell which controller-gen)
80+
endif

PROJECT

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
domain: example.com
2+
repo: skydive
3+
resources:
4+
- group: skydive
5+
kind: SkydiveAgents
6+
version: v1beta1
7+
- group: skydive
8+
kind: SkydiveAnalyzer
9+
version: v1beta1
10+
version: "2"

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!-- ABOUT THE PROJECT -->
2+
3+
# Skydive Operator (WIP)
4+
5+
This is a simple operator to deploy skydive analyzer and agents.
6+
7+
<!-- GETTING STARTED -->
8+
9+
## Getting Started
10+
11+
To set up this operator follow the instructions below:
12+
13+
### Prerequisites
14+
15+
* Make sure you have golang installed on your machine, The go-lang version that this operator was built on is go1.15.7
16+
darwin/amd64
17+
18+
* An openshift cluster
19+
* If you don't have an openshift cluster you may locally install one
20+
using [kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
21+
22+
### Installation
23+
24+
1. If you're running a kind cluster the following commands won't work for you and you will have to modify the project
25+
namespace in the next part
26+
27+
```zsh
28+
oc adm new-project --node-selector='' skydive
29+
oc project skydive
30+
```
31+
32+
2. Run this to grant privileges to your user (#TODO this is maybe not needed)
33+
34+
```zsh
35+
oc adm policy add-scc-to-user privileged -z default
36+
oc adm policy add-cluster-role-to-user cluster-reader -z default
37+
```
38+
39+
3. Clone this repo into your $GOPATH/src folder
40+
4. From skydive-operator folder run:
41+
42+
```bash
43+
make manifests
44+
kubectl create -f config/crd/bases
45+
kubectl create -f config/samples/skydive_v1beta1_skydiveanalyzer.yaml
46+
kubectl create -f config/samples/skydive_v1beta1_skydiveagents.yaml
47+
make run
48+
```
49+
50+
You might need to install some golang packages
51+
(#TODO make sure to see what my IDE auto installed for me)

api/v1beta1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1beta1 contains API Schema definitions for the skydive v1beta1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=skydive.example.com
20+
package v1beta1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "skydive.example.com", Version: "v1beta1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)

api/v1beta1/skydiveagents_types.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// SkydiveAgentsSpec defines the desired state of SkydiveAgents
27+
type SkydiveAgentsSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// Foo is an example field of SkydiveAgents. Edit SkydiveAgents_types.go to remove/update
32+
Foo string `json:"foo,omitempty"`
33+
}
34+
35+
// SkydiveAgentsStatus defines the observed state of SkydiveAgents
36+
type SkydiveAgentsStatus struct {
37+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38+
// Important: Run "make" to regenerate code after modifying this file
39+
}
40+
41+
// +kubebuilder:object:root=true
42+
43+
// SkydiveAgents is the Schema for the skydiveagents API
44+
type SkydiveAgents struct {
45+
metav1.TypeMeta `json:",inline"`
46+
metav1.ObjectMeta `json:"metadata,omitempty"`
47+
48+
Spec SkydiveAgentsSpec `json:"spec,omitempty"`
49+
Status SkydiveAgentsStatus `json:"status,omitempty"`
50+
}
51+
52+
// +kubebuilder:object:root=true
53+
54+
// SkydiveAgentsList contains a list of SkydiveAgents
55+
type SkydiveAgentsList struct {
56+
metav1.TypeMeta `json:",inline"`
57+
metav1.ListMeta `json:"metadata,omitempty"`
58+
Items []SkydiveAgents `json:"items"`
59+
}
60+
61+
func init() {
62+
SchemeBuilder.Register(&SkydiveAgents{}, &SkydiveAgentsList{})
63+
}

api/v1beta1/skydiveanalyzer_types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// SkydiveAnalyzerSpec defines the desired state of SkydiveAnalyzer
27+
type SkydiveAnalyzerSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// +optional
32+
// +kubebuilder:default=1
33+
Replicas *int32 `json:"replicas,omitempty"`
34+
}
35+
36+
// SkydiveAnalyzerStatus defines the observed state of SkydiveAnalyzer
37+
type SkydiveAnalyzerStatus struct {
38+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
39+
// Important: Run "make" to regenerate code after modifying this file
40+
}
41+
42+
// +kubebuilder:object:root=true
43+
// +kubebuilder:subresource:status
44+
45+
// SkydiveAnalyzer is the Schema for the skydiveanalyzers API
46+
type SkydiveAnalyzer struct {
47+
metav1.TypeMeta `json:",inline"`
48+
metav1.ObjectMeta `json:"metadata,omitempty"`
49+
50+
Spec SkydiveAnalyzerSpec `json:"spec,omitempty"`
51+
Status SkydiveAnalyzerStatus `json:"status,omitempty"`
52+
}
53+
54+
// +kubebuilder:object:root=true
55+
56+
// SkydiveAnalyzerList contains a list of SkydiveAnalyzer
57+
type SkydiveAnalyzerList struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ListMeta `json:"metadata,omitempty"`
60+
Items []SkydiveAnalyzer `json:"items"`
61+
}
62+
63+
func init() {
64+
SchemeBuilder.Register(&SkydiveAnalyzer{}, &SkydiveAnalyzerList{})
65+
}

0 commit comments

Comments
 (0)