Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit b7e5c52

Browse files
Adding Base Operator Without Resources
**This change addresses the need by:** * closes #9
1 parent 4a6e619 commit b7e5c52

File tree

19 files changed

+904
-0
lines changed

19 files changed

+904
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
aws-operator
2+
pod-role.json
3+
.DS_Store
4+
aws-operator.yml
5+
kubeconfig
6+
dist/
7+
.envrc

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM alpine
2+
MAINTAINER Christopher Hein <[email protected]>
3+
4+
RUN apk --no-cache add openssl musl-dev ca-certificates
5+
COPY aws-operator /usr/local/bin/
6+
7+
ENTRYPOINT ["/usr/local/bin/aws-operator"]

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
commitSHA := $(shell git describe --dirty --always)
2+
dateStr := $(shell date +%s)
3+
4+
.PHONY: build
5+
build:
6+
go build -ldflags "-X main.commit=$(commitSHA) -X main.date=$(dateStr)" ./cmd/aws-operator
7+
8+
.PHONY: release
9+
release:
10+
rm -fr dist
11+
goreleaser
12+
13+
.PHONY: install-bindata
14+
install-bindata:
15+
go get -u github.com/jteeuwen/go-bindata/...
16+
17+
.PHONY: install-aws-codegen
18+
install-aws-codegen:
19+
go get -u github.com/christopherhein/aws-operator-codegen
20+
21+
# .PHONY: update-bindata
22+
# update-bindata:
23+
# go generate ./pkg/cloudformation/
24+
25+
.PHONY: aws-codegen
26+
aws-codegen:
27+
aws-operator-codegen process
28+
29+
.PHONY: k8s-codegen
30+
k8s-codegen:
31+
./codegen.sh
32+
33+
.PHONY: codegen
34+
codegen: aws-codegen k8s-codegen
35+
36+
.PHONY: rebuild
37+
rebuild: codegen build

codegen.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash -e
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
16+
projectdir="$(pwd | sed "s#$GOPATH\/src\/##g")"
17+
cd ${scriptdir}/vendor/k8s.io/code-generator && ./generate-groups.sh \
18+
all \
19+
${projectdir}/pkg/client \
20+
${projectdir}/pkg/apis \
21+
"operator.aws:v1alpha1" \

configs/aws-operator.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
kind: Namespace
3+
apiVersion: v1
4+
metadata:
5+
name: aws-operator
6+
---
7+
kind: ClusterRole
8+
apiVersion: rbac.authorization.k8s.io/v1beta1
9+
metadata:
10+
name: aws-operator
11+
namespace: aws-operator
12+
rules:
13+
- apiGroups:
14+
- extensions
15+
resources:
16+
- thirdpartyresources
17+
verbs:
18+
- get
19+
- list
20+
- watch
21+
- create
22+
- delete
23+
- update
24+
- apiGroups:
25+
- apiextensions.k8s.io
26+
resources:
27+
- customresourcedefinitions
28+
verbs:
29+
- get
30+
- list
31+
- watch
32+
- create
33+
- delete
34+
- apiGroups:
35+
- operator.aws
36+
resources:
37+
- "*"
38+
verbs:
39+
- "*"
40+
---
41+
apiVersion: v1
42+
kind: ServiceAccount
43+
metadata:
44+
name: aws-operator
45+
namespace: aws-operator
46+
---
47+
kind: ClusterRoleBinding
48+
apiVersion: rbac.authorization.k8s.io/v1beta1
49+
metadata:
50+
name: aws-operator
51+
namespace: aws-operator
52+
roleRef:
53+
apiGroup: rbac.authorization.k8s.io
54+
kind: ClusterRole
55+
name: aws-operator
56+
subjects:
57+
- kind: ServiceAccount
58+
name: aws-operator
59+
namespace: default
60+
# TODO: Uncomment when you have an image to deploy
61+
# ---
62+
# apiVersion: apps/v1beta1
63+
# kind: Deployment
64+
# metadata:
65+
# name: aws-operator
66+
# namespace: aws-operator
67+
# spec:
68+
# replicas: 1
69+
# template:
70+
# metadata:
71+
# labels:
72+
# app: aws-operator
73+
# spec:
74+
# serviceAccountName: aws-operator
75+
# containers:
76+
# - name: aws-operator
77+
# image: christopherhein/aws-operator:VERSION_NUMBER
78+
# imagePullPolicy: Always

examples/.gitkeep

Whitespace-only changes.

models/.gitkeep

Whitespace-only changes.

pkg/apis/operator.aws/register.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package awsio
2+
3+
const (
4+
// GroupName represents the base of this package
5+
GroupName = "operator.aws"
6+
// Version defines the latest version published
7+
Version = "v1alpha1"
8+
)

pkg/apis/operator.aws/v1alpha1/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// +k8s:deepcopy-gen=package,register
2+
3+
// Package v1alpha1 is the v1alpha1 version of the API.
4+
// +groupName=operator.aws
5+
package v1alpha1
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
8+
awsio "github.com/christopherhein/aws-operator/pkg/apis/operator.aws"
9+
)
10+
11+
// SchemeBuilder definition
12+
var (
13+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
14+
localSchemeBuilder = &SchemeBuilder
15+
AddToScheme = SchemeBuilder.AddToScheme
16+
)
17+
18+
// SchemeGroupVersion is group version used to register these objects
19+
var SchemeGroupVersion = schema.GroupVersion{Group: awsio.GroupName, Version: awsio.Version}
20+
21+
func init() {
22+
// We only register manually written functions here. The registration of the
23+
// generated functions takes place in the generated files. The separation
24+
// makes the code compile even when the generated files are missing.
25+
localSchemeBuilder.Register(addKnownTypes)
26+
}
27+
28+
// Resource takes an unqualified resource and returns back a Group qualified GroupResource
29+
func Resource(resource string) schema.GroupResource {
30+
return SchemeGroupVersion.WithResource(resource).GroupResource()
31+
}
32+
33+
// Adds the list of known types to api.Scheme.
34+
func addKnownTypes(scheme *runtime.Scheme) error {
35+
scheme.AddKnownTypes(SchemeGroupVersion)
36+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
37+
return nil
38+
}

0 commit comments

Comments
 (0)