This repository has been archived by the owner on Dec 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor things to clarify which functions are for which platform
This also introduces the idea of configuring the resources *before* they're applied, which in hindsight makes more sense, i.e. make the first configmap the controllers see the correct one. We may want to do the same for the config in the Install CR, but because I'm still unsure whether having the config in there at all is a good idea, I'm keeping it post-install, mostly because the logging is set up to show previous values of whatever it overwrites. Doing that pre-install would require manifestival enhancements. Another thing pre-install config solves is swimming upstream against the controller-runtime caching client, which occasionally fails to find newly-created resources as the informer doesn't yet know about them. See kubernetes-sigs/controller-runtime#180 for more info.
- Loading branch information
1 parent
14d83d7
commit aa755a4
Showing
5 changed files
with
198 additions
and
140 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package install | ||
|
||
import ( | ||
"github.com/openshift-knative/knative-serving-operator/pkg/controller/install/minikube" | ||
) | ||
|
||
func init() { | ||
platformFuncs = append(platformFuncs, minikube.Configure) | ||
} |
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,9 @@ | ||
package install | ||
|
||
import ( | ||
"github.com/openshift-knative/knative-serving-operator/pkg/controller/install/openshift" | ||
) | ||
|
||
func init() { | ||
platformFuncs = append(platformFuncs, openshift.Configure) | ||
} |
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,38 @@ | ||
package minikube | ||
|
||
import ( | ||
"context" | ||
|
||
mf "github.com/jcrossley3/manifestival" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||
) | ||
|
||
var log = logf.Log.WithName("minikube") | ||
|
||
// Configure minikube if we're soaking in it | ||
func Configure(c client.Client, _ *runtime.Scheme) []mf.Transformer { | ||
node := &v1.Node{} | ||
if err := c.Get(context.TODO(), types.NamespacedName{Name: "minikube"}, node); err != nil { | ||
if !errors.IsNotFound(err) { | ||
log.Error(err, "Unable to query for minikube node") | ||
} | ||
return nil // not running on minikube | ||
} | ||
return []mf.Transformer{egress} | ||
} | ||
|
||
func egress(u *unstructured.Unstructured) *unstructured.Unstructured { | ||
if u.GetKind() == "ConfigMap" && u.GetName() == "config-network" { | ||
k, v := "istio.sidecar.includeOutboundIPRanges", "10.0.0.1/24" | ||
log.Info("Setting egress", k, v) | ||
unstructured.SetNestedField(u.Object, v, "data", k) | ||
} | ||
return u | ||
} |
Oops, something went wrong.