-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1627 from hunchback/k8s-configmap-secret
k8s: add configmap and secret objects
- Loading branch information
Showing
10 changed files
with
135 additions
and
0 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: skydive-test-configmap | ||
namespace: default | ||
data: | ||
log_level: INFO |
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,11 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: skydive-test-secret | ||
namespace: default | ||
type: Opaque | ||
data: | ||
# echo -n 'admin' | base64 | ||
# YWRtaW4= | ||
username: YWRtaW4= | ||
password: YWRtaW4= |
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,50 @@ | ||
/* | ||
* Copyright (C) 2018 IBM, Inc. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 k8s | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/skydive-project/skydive/graffiti/graph" | ||
|
||
"k8s.io/api/core/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
type configMapHandler struct { | ||
} | ||
|
||
func (h *configMapHandler) Dump(obj interface{}) string { | ||
cm := obj.(*v1.ConfigMap) | ||
return fmt.Sprintf("configmap{Namespace: %s, Name: %s}", cm.Namespace, cm.Name) | ||
} | ||
|
||
func (h *configMapHandler) Map(obj interface{}) (graph.Identifier, graph.Metadata) { | ||
cm := obj.(*v1.ConfigMap) | ||
m := NewMetadataFields(&cm.ObjectMeta) | ||
return graph.Identifier(cm.GetUID()), NewMetadata(Manager, "configmap", m, cm, cm.Name) | ||
} | ||
|
||
func newConfigMapProbe(client interface{}, g *graph.Graph) Subprobe { | ||
return NewResourceCache(client.(*kubernetes.Clientset).CoreV1().RESTClient(), &v1.ConfigMap{}, "configmaps", g, &configMapHandler{}) | ||
} |
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,51 @@ | ||
/* | ||
* Copyright (C) 2018 IBM, Inc. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 k8s | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/skydive-project/skydive/graffiti/graph" | ||
|
||
"k8s.io/api/core/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
type secretHandler struct { | ||
} | ||
|
||
func (h *secretHandler) Dump(obj interface{}) string { | ||
secret := obj.(*v1.Secret) | ||
return fmt.Sprintf("secret{Namespace: %s, Name: %s}", secret.Namespace, secret.Name) | ||
} | ||
|
||
func (h *secretHandler) Map(obj interface{}) (graph.Identifier, graph.Metadata) { | ||
secret := obj.(*v1.Secret) | ||
m := NewMetadataFields(&secret.ObjectMeta) | ||
m.SetField("Type", secret.Type) | ||
return graph.Identifier(secret.GetUID()), NewMetadata(Manager, "secret", m, secret, secret.Name) | ||
} | ||
|
||
func newSecretProbe(client interface{}, g *graph.Graph) Subprobe { | ||
return NewResourceCache(client.(*kubernetes.Clientset).CoreV1().RESTClient(), &v1.Secret{}, "secrets", g, &secretHandler{}) | ||
} |