-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New external command for scenareos where LBs are attached externally …
…not explicitly via feed (#238) * Working GCP feed with GKE ingress controller, external and internal * External command that doesn't attach to external load baalncers * Add external status updater * Logging * Flags for external and internal host name * Flags for external and internal host name * Formatting * Rename to static
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package external | ||
|
||
import ( | ||
"github.com/sky-uk/feed/controller" | ||
"github.com/sky-uk/feed/k8s" | ||
k8sStatus "github.com/sky-uk/feed/k8s/status" | ||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
// Config for External status updater. | ||
type Config struct { | ||
InternalHostname string | ||
ExternalHostname string | ||
KubernetesClient k8s.Client | ||
} | ||
type status struct { | ||
internalHostname string | ||
externalHostname string | ||
loadBalancers map[string]v1.LoadBalancerStatus | ||
kubernetesClient k8s.Client | ||
} | ||
|
||
// New creates a new External status updater. | ||
func New(conf Config) (controller.Updater, error) { | ||
return &status{ | ||
internalHostname: conf.InternalHostname, | ||
externalHostname: conf.ExternalHostname, | ||
loadBalancers: make(map[string]v1.LoadBalancerStatus), | ||
kubernetesClient: conf.KubernetesClient, | ||
}, nil | ||
} | ||
|
||
func (s *status) Start() error { | ||
s.loadBalancers["internal"] = k8sStatus.GenerateLoadBalancerStatus([]string{s.internalHostname}) | ||
s.loadBalancers["internet-facing"] = k8sStatus.GenerateLoadBalancerStatus([]string{s.externalHostname}) | ||
return nil | ||
} | ||
|
||
func (s *status) Stop() error { | ||
return nil | ||
} | ||
|
||
func (s *status) Health() error { | ||
return nil | ||
} | ||
|
||
func (s *status) Update(ingresses controller.IngressEntries) error { | ||
return k8sStatus.Update(ingresses, s.loadBalancers, s.kubernetesClient) | ||
} |
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,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/sky-uk/feed/controller" | ||
"github.com/sky-uk/feed/external" | ||
"github.com/sky-uk/feed/k8s" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
externalHostname string | ||
internalHostName string | ||
) | ||
|
||
var externalCmd = &cobra.Command{ | ||
Use: "static", | ||
Short: "Static hostname set for internal and external ingress", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
runCmd(empty) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(externalCmd) | ||
|
||
externalCmd.Flags().StringVar(&externalHostname, "external-hostname", "", | ||
"Hostname for external ingress") | ||
externalCmd.Flags().StringVar(&internalHostName, "internal-hostname", "", | ||
"Hostname for internal ingress") | ||
|
||
} | ||
|
||
func empty(kubernetesClient k8s.Client, updaters []controller.Updater) ([]controller.Updater, error) { | ||
|
||
config := external.Config{ | ||
InternalHostname: internalHostName, | ||
ExternalHostname: externalHostname, | ||
KubernetesClient: kubernetesClient, | ||
} | ||
statusUpdater, err := external.New(config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return append(updaters, statusUpdater), nil | ||
} |