Skip to content

Commit

Permalink
fix(components) Overwrite entrypoint of registry containers
Browse files Browse the repository at this point in the history
Fix core configuration by using gomplate
Fix registry image in config/samples

Signed-off-by: Pierre Péronnet <pierre.peronnet@corp.ovh.com>
  • Loading branch information
holyhope committed Jan 31, 2020
1 parent f096707 commit 747036b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets/templates/core/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ runmode = prod
enablegzip = true

[prod]
httpport = 8080
httpport = {{ env.Getenv "PORT" }}
2 changes: 1 addition & 1 deletion assets/templates/registry/ctl-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
protocol: "http"
port: {{ env.Getenv "PORT" }}
port: {{ env.Getenv "REGISTRYCTL_PORT" }}
log_level: info
2 changes: 1 addition & 1 deletion config/samples/containerregistry_v1alpha1_harbor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
registry:
storageSecret: registry-storage
cacheSecret: registry-cache
image: goharbor/registry-photon:v2.7.1-patch-2819-v1.10.0
image: goharbor/registry-photon:v2.7.1-patch-2819-2553-v1.10.0
jobService:
redisSecret: jobservice-redis
image: goharbor/harbor-jobservice:v1.10.0
Expand Down
38 changes: 37 additions & 1 deletion controllers/harbor/components/harbor-core/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package core

import (
"context"
"fmt"
"path"
"time"

appsv1 "k8s.io/api/apps/v1"
Expand All @@ -22,7 +24,8 @@ var (
)

const (
coreConfigPath = "/etc/core/app.conf"
initImage = "hairyhenderson/gomplate"
coreConfigPath = "/etc/core/"
keyFileName = "key"
port = 8080 // https://github.com/goharbor/harbor/blob/2fb1cc89d9ef9313842cc68b4b7c36be73681505/src/common/const.go#L127

Expand Down Expand Up @@ -85,6 +88,11 @@ func (c *HarborCore) GetDeployments(ctx context.Context) []*appsv1.Deployment {
Volumes: []corev1.Volume{
{
Name: "config",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
}, {
Name: "config-template",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Expand Down Expand Up @@ -120,6 +128,34 @@ func (c *HarborCore) GetDeployments(ctx context.Context) []*appsv1.Deployment {
},
},
},
InitContainers: []corev1.Container{
{
Name: "registry-configuration",
Image: initImage,
WorkingDir: "/workdir",
Args: []string{"--input-dir", "/workdir", "--output-dir", "/processed"},
SecurityContext: &corev1.SecurityContext{},

VolumeMounts: []corev1.VolumeMount{
{
Name: "config-template",
MountPath: path.Join("/workdir", configName),
ReadOnly: true,
SubPath: configName,
}, {
Name: "config",
MountPath: "/processed",
ReadOnly: false,
},
},
Env: []corev1.EnvVar{
{
Name: "PORT",
Value: fmt.Sprintf("%d", port),
},
},
},
},
Containers: []corev1.Container{
{
Name: "core",
Expand Down
16 changes: 9 additions & 7 deletions controllers/harbor/components/registry/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ func (r *Registry) GetDeployments(ctx context.Context) []*appsv1.Deployment { //
}, {
Name: "API_ADDRESS",
Value: fmt.Sprintf(":%d", apiPort),
}, {
Name: "REGISTRYCTL_PORT",
Value: fmt.Sprintf("%d", ctlAPIPort),
},
cacheEnv,
},
Expand Down Expand Up @@ -197,9 +200,6 @@ func (r *Registry) GetDeployments(ctx context.Context) []*appsv1.Deployment { //
},
},
},
}, {
Name: "REGISTRY_STORAGE_INMEMORY",
Value: "",
}, {
Name: "REGISTRY_HTTP_HOST",
Value: r.harbor.Spec.PublicURL,
Expand Down Expand Up @@ -233,7 +233,7 @@ func (r *Registry) GetDeployments(ctx context.Context) []*appsv1.Deployment { //
},
VolumeMounts: []corev1.VolumeMount{
{
MountPath: path.Join(registryCtlConfigPath, registryConfigName),
MountPath: path.Join(registryCtlConfigPath, registryCtlConfigName),
Name: "config",
SubPath: registryCtlConfigName,
}, {
Expand All @@ -246,8 +246,9 @@ func (r *Registry) GetDeployments(ctx context.Context) []*appsv1.Deployment { //
SubPath: "ca.crt",
},
},
},
{
Command: []string{"/home/harbor/harbor_registryctl"},
Args: []string{"-c", path.Join(registryCtlConfigPath, registryCtlConfigName)},
}, {
Name: "registry",
Image: r.harbor.Spec.Components.Registry.Image,
Ports: []corev1.ContainerPort{
Expand Down Expand Up @@ -306,7 +307,8 @@ func (r *Registry) GetDeployments(ctx context.Context) []*appsv1.Deployment { //
SubPath: "ca.crt",
},
},
Args: []string{"serve", path.Join(registryConfigPath, registryConfigName)},
Command: []string{"/usr/bin/registry"},
Args: []string{"serve", path.Join(registryConfigPath, registryConfigName)},
},
},
Priority: r.Option.Priority,
Expand Down

0 comments on commit 747036b

Please sign in to comment.