aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/healthcheck/kubeclient.go
diff options
context:
space:
mode:
authorKonrad Bańka <k.banka@samsung.com>2021-02-25 00:08:05 +0100
committerKonrad Bańka <k.banka@samsung.com>2021-02-25 15:30:45 +0100
commit22a37f42a54c1acd2f095bc559ab03745e5ae7f9 (patch)
tree18be25e5475c5bf8d00d2e43a734d4eca2658a7b /src/k8splugin/internal/healthcheck/kubeclient.go
parentfec64d4a5d7986e4d92b1350f31c9a3c81e82e6e (diff)
Provide Healthcheck API MVP0.8.0
Implements basic functionality of running starting Healthcheck. Results can be inspected so-far without dedicated API, by using, for example, Query API. Issue-ID: MULTICLOUD-1233 Signed-off-by: Konrad Bańka <k.banka@samsung.com> Change-Id: Ia4d96d936d573173d7d8f41e6c39d059bf5f8b1f
Diffstat (limited to 'src/k8splugin/internal/healthcheck/kubeclient.go')
-rw-r--r--src/k8splugin/internal/healthcheck/kubeclient.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/k8splugin/internal/healthcheck/kubeclient.go b/src/k8splugin/internal/healthcheck/kubeclient.go
new file mode 100644
index 00000000..be4c6fcc
--- /dev/null
+++ b/src/k8splugin/internal/healthcheck/kubeclient.go
@@ -0,0 +1,59 @@
+/*
+Copyright © 2021 Samsung Electronics
+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 healthcheck
+
+import (
+ "k8s.io/helm/pkg/kube"
+ "k8s.io/helm/pkg/tiller/environment"
+
+ "github.com/onap/multicloud-k8s/src/k8splugin/internal/app"
+ "github.com/onap/multicloud-k8s/src/k8splugin/internal/config"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+//implements environment.KubeClient but overrides it so that
+//custom labels can be injected into created resources
+// using internal k8sClient
+type KubeClientImpl struct {
+ environment.KubeClient
+ labels map[string]string
+ k app.KubernetesClient
+}
+
+func NewKubeClient(instanceId, cloudRegion string) (*KubeClientImpl, error) {
+ k8sClient := app.KubernetesClient{}
+ err := k8sClient.Init(cloudRegion, instanceId)
+ if err != nil {
+ return nil, pkgerrors.Wrap(err, "Initializing k8sClient")
+ }
+ return &KubeClientImpl{
+ labels: map[string]string{
+ config.GetConfiguration().KubernetesLabelName: instanceId,
+ },
+ KubeClient: kube.New(&k8sClient),
+ k: k8sClient,
+ }, nil
+}
+
+/* FIXME
+// Need to correct this later and provide override of Create method to use our k8sClient
+// So that healthcheck hook resources would be labeled with vf-module data just like currently
+// every k8splugin-managed resource is
+
+//Create function is overrided to label test resources with custom labels
+func (kci *KubeClientImpl) Create(namespace string, reader io.Reader, timeout int64, shouldWait bool) error {
+ return nil
+}
+*/