generated from giantswarm/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add cilium netpol creation * fix code errors * remove unused libraries * fix go build error * use correct k8s client * add ciliumnetpol resource to managementcluster controller * fix prometheus resource * add missing kind and apiVersion to object * try with dynamic client * add dynamic client to controller * add dynamic client definition in service * add cilium netpol in clusterrole * Update helm/prometheus-meta-operator/templates/rbac.yaml Co-authored-by: Fernando Ripoll <[email protected]> * try to solve creating issue * fix ports definition for ingress * add cilium netpol creation to clusterapi controller * add dynamic client to clusterapi controller in service * rearrange code * changed K8s.io/api version to 0.29.0 * updated libraries --------- Co-authored-by: Fernando Ripoll <[email protected]>
- Loading branch information
1 parent
f02de74
commit 96ea389
Showing
14 changed files
with
307 additions
and
32 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
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
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
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,37 @@ | ||
package ciliumnetpol | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/giantswarm/microerror" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
func (r *Resource) EnsureCreated(ctx context.Context, obj interface{}) error { | ||
r.logger.Debugf(ctx, "creating") | ||
{ | ||
resource := schema.GroupVersionResource{ | ||
Group: "cilium.io", | ||
Version: "v2", | ||
Resource: "ciliumnetworkpolicies", | ||
} | ||
|
||
desired, err := toCiliumNetworkPolicy(obj) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
_, err = r.dynamicK8sClient.Resource(resource).Get(ctx, desired.GetName(), metav1.GetOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
_, err = r.dynamicK8sClient.Resource(resource).Namespace(desired.GetNamespace()).Create(ctx, desired, metav1.CreateOptions{}) | ||
} | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
} | ||
r.logger.Debugf(ctx, "created") | ||
|
||
return nil | ||
} |
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,36 @@ | ||
package ciliumnetpol | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/giantswarm/microerror" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
func (r *Resource) EnsureDeleted(ctx context.Context, obj interface{}) error { | ||
r.logger.Debugf(ctx, "deleting") | ||
{ | ||
resource := schema.GroupVersionResource{ | ||
Group: "cilium.io", | ||
Version: "v2", | ||
Resource: "ciliumnetworkpolicies", | ||
} | ||
|
||
desired, err := toCiliumNetworkPolicy(obj) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
err = r.dynamicK8sClient.Resource(resource).Namespace(desired.GetNamespace()).Delete(ctx, desired.GetName(), metav1.DeleteOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
// fall through | ||
} else if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
} | ||
r.logger.Debugf(ctx, "deleted") | ||
|
||
return nil | ||
} |
Oops, something went wrong.