This repository has been archived by the owner on Nov 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #43 from manifoldco/drosati/4186-imagepolicy-contr…
…oller add image policy controller
- Loading branch information
Showing
15 changed files
with
599 additions
and
269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/jelmersnoeck/kubekit" | ||
flags "github.com/jessevdk/go-flags" | ||
"github.com/manifoldco/heighliner/pkg/imagepolicy" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
ipcCmd = &cobra.Command{ | ||
Use: "ipc", | ||
Short: "Run the Image Policy Controller", | ||
RunE: ipcCommand, | ||
} | ||
|
||
ipcFlags struct { | ||
Namespace string `long:"namespace" env:"NAMESPACE" description:"The namespace to run the controller in. By default we'll watch all namespaces."` | ||
} | ||
) | ||
|
||
func ipcCommand(cmd *cobra.Command, args []string) error { | ||
if _, err := flags.ParseArgs(&ipcFlags, append(args, os.Args...)); err != nil { | ||
log.Printf("Could not parse flags: %s", err) | ||
return err | ||
} | ||
|
||
cfg, cs, acs, err := kubekit.InClusterClientsets() | ||
if err != nil { | ||
log.Printf("Could not get Clientset: %s\n", err) | ||
return err | ||
} | ||
|
||
if err := kubekit.CreateCRD(acs, imagepolicy.ImagePolicyResource); err != nil { | ||
log.Printf("Could not create ImagePolicy CRD: %s\n", err) | ||
return err | ||
} | ||
|
||
ctrl, err := imagepolicy.NewController(cfg, cs, ipcFlags.Namespace) | ||
if err != nil { | ||
log.Printf("Could not create controller: %s\n", err) | ||
return err | ||
} | ||
|
||
if err := ctrl.Run(); err != nil { | ||
log.Printf("Error running controller: %s\n", err) | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(ipcCmd) | ||
} |
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,69 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRole | ||
metadata: | ||
name: heighliner:image-policy | ||
rules: | ||
- apiGroups: ["hlnr.io"] | ||
resources: ["imagepolicies"] | ||
verbs: ["*"] | ||
- apiGroups: ["hlnr.io"] | ||
resources: ["microservices"] | ||
verbs: ["get", "list"] | ||
- apiGroups: ["extensions"] | ||
resources: ["ingresses"] | ||
verbs: ["*"] | ||
- apiGroups: [""] | ||
resources: ["services"] | ||
verbs: ["*"] | ||
- apiGroups: ["apiextensions.k8s.io"] | ||
resources: ["customresourcedefinitions"] | ||
verbs: ["*"] | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: heighliner:image-policy | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: heighliner:image-policy | ||
subjects: | ||
- name: heighliner-image-policy | ||
namespace: hlnr-system | ||
kind: ServiceAccount | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: heighliner-image-policy | ||
namespace: hlnr-system | ||
|
||
--- | ||
|
||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: image-policy-controller | ||
namespace: hlnr-system | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: image-policy-controller | ||
spec: | ||
serviceAccountName: heighliner-image-policy | ||
containers: | ||
- name: image-policy-controller | ||
image: arigato/heighliner:latest | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- ipc | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 10Mi |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.