Skip to content

Commit 1cae937

Browse files
committed
example working
1 parent 27955fb commit 1cae937

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

examples/kcp/main.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121
"fmt"
2222
"os"
2323

24+
corev1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/runtime"
27+
2628
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
2729
ctrl "sigs.k8s.io/controller-runtime"
2830
api "sigs.k8s.io/controller-runtime/examples/crd/pkg"
@@ -56,6 +58,25 @@ func (r *reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
5658
return ctrl.Result{}, err
5759
}
5860

61+
cm := &corev1.ConfigMap{
62+
TypeMeta: metav1.TypeMeta{
63+
APIVersion: "v1",
64+
Kind: "ConfigMap",
65+
},
66+
ObjectMeta: metav1.ObjectMeta{
67+
Name: "test-cm",
68+
Namespace: "default",
69+
ClusterName: req.ClusterName,
70+
},
71+
Data: map[string]string{
72+
"test-key": "test-value",
73+
},
74+
}
75+
if err := r.Create(ctx, cm); err != nil {
76+
log.Error(err, "unable to create configmap")
77+
return ctrl.Result{}, err
78+
}
79+
5980
return ctrl.Result{}, nil
6081
}
6182

@@ -78,6 +99,11 @@ func main() {
7899
setupLog.Error(err, "unable to add scheme")
79100
os.Exit(1)
80101
}
102+
err = corev1.AddToScheme(mgr.GetScheme())
103+
if err != nil {
104+
setupLog.Error(err, "unable to add scheme")
105+
os.Exit(1)
106+
}
81107

82108
err = ctrl.NewControllerManagedBy(mgr).
83109
For(&api.ChaosPod{}).

0 commit comments

Comments
 (0)