-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACI CNI Operator for OpenShift4.X/K8s Platform
- Loading branch information
Showing
32 changed files
with
2,146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2020 Cisco Systems, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
log "github.com/Sirupsen/logrus" | ||
operatorclientset "github.com/noironetworks/aci-containers/pkg/acicontainersoperator/clientset/versioned" | ||
"github.com/noironetworks/aci-containers/pkg/controller" | ||
restclient "k8s.io/client-go/rest" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
) | ||
|
||
// Create K8s Client | ||
func getOperatorClient() operatorclientset.Interface { | ||
|
||
restconfig, err := restclient.InClusterConfig() | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
kubeClient, err := operatorclientset.NewForConfig(restconfig) | ||
if err != nil { | ||
log.Fatalf("Failed to intialize kube client %v", err) | ||
} | ||
|
||
log.Info("Successfully constructed k8s client") | ||
return kubeClient | ||
} | ||
|
||
|
||
func main() { | ||
// get the Kubernetes client for connectivity | ||
log.Debug("Initializing kubernetes client") | ||
client := getOperatorClient() | ||
if client == nil{ | ||
log.Fatalf("Failed to intialize kube client", ) | ||
return | ||
} | ||
|
||
cont := controller.NewAciContainersOperator(client) | ||
|
||
stopCh := make(chan struct{}) | ||
defer close(stopCh) | ||
go cont.Run(stopCh) | ||
|
||
sig := make(chan os.Signal, 1) | ||
signal.Notify(sig, syscall.SIGTERM) | ||
signal.Notify(sig, syscall.SIGINT) | ||
<-sig | ||
} |
12 changes: 12 additions & 0 deletions
12
crd-code-generation/hack/update-codegen-containersoperator.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_ROOT=$(dirname ${PWD}) | ||
|
||
vendor/k8s.io/code-generator/generate-groups.sh all \ | ||
github.com/noironetworks/aci-containers/pkg/acicontainersoperator github.com/noironetworks/aci-containers/pkg/acicontainersoperator/apis \ | ||
aci.ctrl:v1alpha1 \ | ||
--go-header-file ${SCRIPT_ROOT}/aci-containers/crd-code-generation/hack/custom-boilerplate.go.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine:3.10.2 | ||
RUN apk upgrade --no-cache | ||
RUN apk update && apk add curl git | ||
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.14.6/bin/linux/amd64/kubectl | ||
RUN chmod u+x kubectl && mv kubectl /usr/local/bin/kubectl | ||
COPY dist-static/aci-containers-operator /usr/local/bin/ | ||
ENTRYPOINT ["/usr/local/bin/aci-containers-operator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package acictrl | ||
|
||
const ( | ||
GroupName = "aci.ctrl" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// +k8s:deepcopy-gen=package,register | ||
|
||
// Package v1 is the v1 version of the API. | ||
// +groupName=aci.ctrl | ||
package v1alpha1 |
40 changes: 40 additions & 0 deletions
40
pkg/acicontainersoperator/apis/aci.ctrl/v1alpha1/register.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
|
||
operator "github.com/noironetworks/aci-containers/pkg/acicontainersoperator/apis/aci.ctrl" | ||
) | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: operator.GroupName, Version: "v1alpha1"} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
var ( | ||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. | ||
SchemeBuilder runtime.SchemeBuilder | ||
localSchemeBuilder = &SchemeBuilder | ||
AddToScheme = localSchemeBuilder.AddToScheme | ||
) | ||
|
||
func init() { | ||
// We only register manually written functions here. The registration of the | ||
// generated functions takes place in the generated files. The separation | ||
// makes the code compile even when the generated files are missing. | ||
localSchemeBuilder.Register(addKnownTypes) | ||
} | ||
|
||
// Adds the list of known types to api.Scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&AciContainersOperator{}, | ||
) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// AciContainersOperator is a specification for a AciContainersOperator resource | ||
type AciContainersOperator struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AciContainersOperatorSpec `json:"spec,omitempty"` | ||
Status AciContainersOperatorStatus `json:"status,omitempty"` | ||
} | ||
|
||
// AciContainersOperatorSpec defines the desired state of AciContainersOperator | ||
type AciContainersOperatorSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "acioperator-sdk generate k8s" to regenerate code after modifying this file | ||
// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html | ||
Flavor string `json:"flavor"` | ||
Config string `json:"config"` | ||
} | ||
|
||
// AciContainersOperatorStatus defines the observed state of AciContainersOperator | ||
type AciContainersOperatorStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "acioperator-sdk generate k8s" to regenerate code after modifying this file | ||
// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html | ||
Status bool `json:"Successful or Not"` | ||
} | ||
|
||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// AciContainersOperator list | ||
type AciContainersOperatorList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AciContainersOperator `json:"items"` | ||
} |
117 changes: 117 additions & 0 deletions
117
pkg/acicontainersoperator/apis/aci.ctrl/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.