-
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 472edaf
Showing
91 changed files
with
7,358 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=0"] | ||
|
||
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,89 @@ | ||
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/klog" | ||
"k8s.io/klog/klogr" | ||
|
||
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 | ||
} | ||
|
||
var logger = klogr.New().WithName("keda_metrics_adapter") | ||
|
||
func (a *Adapter) makeProviderOrDie() provider.MetricsProvider { | ||
|
||
// Get a config to talk to the apiserver | ||
cfg, err := config.GetConfig() | ||
if err != nil { | ||
logger.Error(err, "failed to get the config") | ||
os.Exit(1) | ||
} | ||
|
||
scheme := scheme.Scheme | ||
if err := appsv1.SchemeBuilder.AddToScheme(scheme); err != nil { | ||
logger.Error(err, "failed to add apps/v1 scheme to runtime scheme") | ||
os.Exit(1) | ||
} | ||
if err := kedav1alpha1.SchemeBuilder.AddToScheme(scheme); err != nil { | ||
logger.Error(err, "failed to add keda scheme to runtime scheme") | ||
os.Exit(1) | ||
} | ||
|
||
kubeclient, err := client.New(cfg, client.Options{ | ||
Scheme: scheme, | ||
}) | ||
if err != nil { | ||
logger.Error(err, "unable to construct new client") | ||
os.Exit(1) | ||
} | ||
|
||
handler := handler.NewScaleHandler(kubeclient, scheme) | ||
|
||
namespace, err := k8sutil.GetWatchNamespace() | ||
if err != nil { | ||
logger.Error(err, "failed to get watch namespace") | ||
os.Exit(1) | ||
} | ||
|
||
return kedaprovider.NewProvider(logger, handler, kubeclient, namespace) | ||
} | ||
|
||
func main() { | ||
defer klog.Flush() | ||
|
||
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) | ||
|
||
logger.Info(cmd.Message) | ||
if err := cmd.Run(wait.NeverStop); err != nil { | ||
logger.Error(err, "unable to run external metrics adapter") | ||
os.Exit(1) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.