Fixed dockerfile build

This commit is contained in:
Jakub Vavřík
2021-06-28 15:14:24 +02:00
parent 4818569d96
commit c02949b79d
3 changed files with 23 additions and 23 deletions

View File

@@ -2,9 +2,9 @@
The responsibility of this webhook is to patch all newly created/updated namespaces so that they contain predefined empty secret with given annotation. The responsibility of this webhook is to patch all newly created/updated namespaces so that they contain predefined empty secret with given annotation.
This repo produces one helm chart available via helm repository https://ysoftdevs.github.io/imagepullsecret-injector. There are also 2 docker images: This repo produces one helm chart available via helm repository https://ysoftdevs.github.io/secret-duplicator. There are also 2 docker images:
- `ghcr.io/ysoftdevs/imagepullsecret-injector/imagepullsecret-injector` - the image containing the webhook itself - `ghcr.io/ysoftdevs/secret-duplicator/secret-duplicator` - the image containing the webhook itself
- `ghcr.io/ysoftdevs/imagepullsecret-injector/webhook-cert-generator` - helper image responsible for (re)generating the certificates - `ghcr.io/ysoftdevs/secret-duplicator/webhook-cert-generator` - helper image responsible for (re)generating the certificates
## Helm description ## Helm description
The helm chart consists of 2 parts: the certificate generator and the webhook configuration itself. The helm chart consists of 2 parts: the certificate generator and the webhook configuration itself.
@@ -26,9 +26,9 @@ Of note is also a fact that the chart runs a lookup to the connected cluster to
## Running locally ## Running locally
1. Create the prerequisite resources: 1. Create the prerequisite resources:
```bash ```bash
kubectl create ns secret-replicator kubectl create ns secret-duplicator
kubectl create secret -n secret-replicator \ kubectl create secret -n secret-duplicator \
generic acr-dockerconfigjson-source \ generic acr-dockerconfigjson-source \
--type=kubernetes.io/dockerconfigjson \ --type=kubernetes.io/dockerconfigjson \
--from-literal=.dockerconfigjson='<your .dockerconfigjson configuration file>' --from-literal=.dockerconfigjson='<your .dockerconfigjson configuration file>'
@@ -37,17 +37,17 @@ Of note is also a fact that the chart runs a lookup to the connected cluster to
1. Build the images and run the chart 1. Build the images and run the chart
``` bash ``` bash
make build-image make build-image
helm upgrade -i secret-replicator \ helm upgrade -i secret-duplicator \
-n secret-replicator \ -n secret-duplicator \
charts/secret-replicator charts/secret-duplicator
``` ```
Alternatively, you can use the pre-built, publicly available helm chart and docker images: Alternatively, you can use the pre-built, publicly available helm chart and docker images:
```bash ```bash
helm repo add secret-replicator https://ysoftdevs.github.io/secret-replicator helm repo add secret-duplicator https://ysoftdevs.github.io/secret-duplicator
helm repo update helm repo update
helm upgrade -i secret-replicator \ helm upgrade -i secret-duplicator \
-n secret-replicator \ -n secret-duplicator \
secret-replicator/secret-replicator secret-duplicator/secret-duplicator
``` ```
1. To test whether everything works, you can run 1. To test whether everything works, you can run

View File

@@ -1,10 +1,10 @@
FROM golang:1.15 AS builder FROM golang:1.15 AS builder
WORKDIR /go/src/github.com/ysoftdevs/imagepullsecret-injector WORKDIR /go/src/github.com/ysoftdevs/secret-duplicator
COPY . . COPY . .
RUN make build RUN make build
FROM alpine:3.13.4 as base FROM alpine:3.13.4 as base
COPY --from=builder /go/src/github.com/ysoftdevs/imagepullsecret-injector/build/_output/bin/imagepullsecret-injector /usr/local/bin/imagepullsecret-injector COPY --from=builder /go/src/github.com/ysoftdevs/secret-duplicator/build/_output/bin/secret-duplicator /usr/local/bin/secret-duplicator
ENTRYPOINT ["imagepullsecret-injector"] ENTRYPOINT ["secret-duplicator"]

View File

@@ -77,11 +77,11 @@ func NewWebhookServer(parameters *WhSvrParameters, server *http.Server) (*Webhoo
// DefaultParametersObject returns a parameters object with the default values // DefaultParametersObject returns a parameters object with the default values
func DefaultParametersObject() WhSvrParameters { func DefaultParametersObject() WhSvrParameters {
return WhSvrParameters{ return WhSvrParameters{
port: 8443, port: 8443,
certFile: "/etc/webhook/certs/cert.pem", certFile: "/etc/webhook/certs/cert.pem",
keyFile: "/etc/webhook/certs/key.pem", keyFile: "/etc/webhook/certs/key.pem",
excludeNamespaces: strings.Join(defaultIgnoredNamespaces, ","), excludeNamespaces: strings.Join(defaultIgnoredNamespaces, ","),
targetSecretName: "dashboard-terminal-kube-apiserver-tls", targetSecretName: "dashboard-terminal-kube-apiserver-tls",
targetSecretAnnotation: "reflector.v1.k8s.emberstack.com/reflects=cert-manager/default-cert", targetSecretAnnotation: "reflector.v1.k8s.emberstack.com/reflects=cert-manager/default-cert",
} }
} }
@@ -214,7 +214,7 @@ func (whsvr *WebhookServer) mutateNamespace(ar *v1beta1.AdmissionReview) *v1beta
if item.Name == whsvr.config.targetSecretName { if item.Name == whsvr.config.targetSecretName {
annotationToCheck := strings.Split(whsvr.config.targetSecretAnnotation, "=") annotationToCheck := strings.Split(whsvr.config.targetSecretAnnotation, "=")
if val, ok := item.Annotations[annotationToCheck[0]]; ok { if val, ok := item.Annotations[annotationToCheck[0]]; ok {
glog.Infof("Namespace is already in the correct state and contains secret %s with value %s=%s, skipping", whsvr.config.targetSecretName, annotationToCheck ,val) glog.Infof("Namespace is already in the correct state and contains secret %s with value %s=%s, skipping", whsvr.config.targetSecretName, annotationToCheck, val)
return &v1beta1.AdmissionResponse{ return &v1beta1.AdmissionResponse{
Allowed: true, Allowed: true,
} }
@@ -234,8 +234,8 @@ func (whsvr *WebhookServer) mutateNamespace(ar *v1beta1.AdmissionReview) *v1beta
} }
return &v1beta1.AdmissionResponse{ return &v1beta1.AdmissionResponse{
Allowed: true, Allowed: true,
Patch: nil, Patch: nil,
PatchType: nil, PatchType: nil,
} }
} }