-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zbynek Roubalik
committed
Oct 18, 2019
1 parent
e5594a7
commit 8b62b50
Showing
91 changed files
with
7,367 additions
and
3,745 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,3 +337,6 @@ apiserver.local.config/ | |
config | ||
*.cert | ||
*.key | ||
|
||
# VSCode specific files | ||
.vscode |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,15 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
||
ENV OPERATOR=/usr/local/bin/keda \ | ||
USER_UID=1001 \ | ||
USER_NAME=keda | ||
|
||
# install operator binary | ||
COPY build/_output/bin/keda ${OPERATOR} | ||
|
||
COPY build/bin /usr/local/bin | ||
RUN /usr/local/bin/user_setup | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint"] | ||
|
||
USER ${USER_UID} |
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,19 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
||
ENV OPERATOR=/usr/local/bin/keda-adapter \ | ||
USER_UID=1001 \ | ||
USER_NAME=keda | ||
|
||
COPY build/_output/bin/keda-adapter ${OPERATOR} | ||
|
||
COPY build/bin /usr/local/bin | ||
RUN /usr/local/bin/user_setup && \ | ||
mkdir /adapter && \ | ||
chmod 777 /adapter && \ | ||
chmod +x ${OPERATOR} | ||
|
||
WORKDIR /adapter | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint", "--secure-port=6443", "--logtostderr=true", "--v=2"] | ||
|
||
USER ${USER_UID} |
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,82 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
"github.com/kedacore/keda/pkg/handler" | ||
kedaprovider "github.com/kedacore/keda/pkg/provider" | ||
|
||
"k8s.io/apimachinery/pkg/util/wait" | ||
"k8s.io/component-base/logs" | ||
"k8s.io/klog" | ||
|
||
kedav1alpha1 "github.com/kedacore/keda/pkg/apis/keda/v1alpha1" | ||
"github.com/operator-framework/operator-sdk/pkg/k8sutil" | ||
appsv1 "k8s.io/api/apps/v1" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
|
||
basecmd "github.com/kubernetes-incubator/custom-metrics-apiserver/pkg/cmd" | ||
"github.com/kubernetes-incubator/custom-metrics-apiserver/pkg/provider" | ||
) | ||
|
||
// Adapter creates External Metrics Provider | ||
type Adapter struct { | ||
basecmd.AdapterBase | ||
|
||
// Message is printed on succesful startup | ||
Message string | ||
} | ||
|
||
func (a *Adapter) makeProviderOrDie() provider.MetricsProvider { | ||
|
||
// Get a config to talk to the apiserver | ||
cfg, err := config.GetConfig() | ||
if err != nil { | ||
klog.Fatalf("failed to get the config: %v", err) | ||
} | ||
|
||
scheme := scheme.Scheme | ||
if err := appsv1.SchemeBuilder.AddToScheme(scheme); err != nil { | ||
klog.Fatalf("failed to add apps/v1 scheme to runtime scheme: (%v)", err) | ||
} | ||
if err := kedav1alpha1.SchemeBuilder.AddToScheme(scheme); err != nil { | ||
klog.Fatalf("failed to add keda scheme to runtime scheme: (%v)", err) | ||
} | ||
|
||
kubeclient, err := client.New(cfg, client.Options{ | ||
Scheme: scheme, | ||
}) | ||
if err != nil { | ||
klog.Fatalf("unable to construct new client: %v", err) | ||
} | ||
|
||
handler := handler.NewScaleHandler(kubeclient, scheme) | ||
|
||
namespace, err := k8sutil.GetWatchNamespace() | ||
if err != nil { | ||
klog.Fatalf("failed to get watch namespace: %v", err) | ||
} | ||
|
||
return kedaprovider.NewProvider(handler, kubeclient, namespace) | ||
} | ||
|
||
func main() { | ||
logs.InitLogs() | ||
defer logs.FlushLogs() | ||
|
||
cmd := &Adapter{} | ||
cmd.Flags().StringVar(&cmd.Message, "msg", "starting adapter...", "startup message") | ||
cmd.Flags().AddGoFlagSet(flag.CommandLine) // make sure we get the klog flags | ||
cmd.Flags().Parse(os.Args) | ||
|
||
kedaProvider := cmd.makeProviderOrDie() | ||
cmd.WithExternalMetrics(kedaProvider) | ||
|
||
klog.Infof(cmd.Message) | ||
if err := cmd.Run(wait.NeverStop); err != nil { | ||
klog.Fatalf("unable to run external metrics adapter: %v", err) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.