-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 Duplicate kinto builder docker secret in each user namespace (#27)
- Loading branch information
Showing
5 changed files
with
88 additions
and
34 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 |
---|---|---|
|
@@ -2,28 +2,38 @@ KUBE_CONFIG_PATH=/Users/<USER_NAME>/.kube/config | |
|
||
## verbose | debug | info | warn | error | fatal | panic | ||
LOG_LEVEL=debug | ||
|
||
GRPC_PORT=8080 | ||
GRPC_WEB_PORT=8090 | ||
GRPC_WEB_PORT=8090 # Port number accessed by the dashboard | ||
|
||
## Domain/Subdomain used to create external name for api and web app services | ||
KINTO_DOMAIN=oss.kintohub.net | ||
|
||
## Kinto Builder api host (see https://github.com/kintoproj/kinto-builder) | ||
BUILD_API_HOST=kinto-builder:8080 | ||
|
||
## Max time in past to send to client on initial connection | ||
CONSOLE_LOGS_HISTORY_SECONDS=93600 | ||
## Max lines to send to client on initial connection. If more than this number, it won't be sent to the client | ||
CONSOLE_LOGS_MAX_LINES_ON_START=1000 | ||
## Logs configuration | ||
CONSOLE_LOGS_HISTORY_SECONDS=93600 # Max time in past to send to client on initial connection | ||
CONSOLE_LOGS_MAX_LINES_ON_START=1000 # Max lines to send to client on initial connection. | ||
|
||
## If false, all external access will be create without certificates | ||
SSL_ENABLED=false | ||
## SSL configuration | ||
SSL_ENABLED=false # If false, all external access will be create without certificates | ||
[email protected] | ||
CERT_MANAGER_ISSUER_SERVER=https://acme-staging-v02.api.letsencrypt.org/directory | ||
|
||
## Allowed host for CORS. Defaults to * which allows everything. kintohub.com,www.kintohub.com is accepted | ||
## Allowed host for CORS. Defaults to * which allows everything. | ||
CORS_ALLOWED_HOST=* | ||
|
||
## Metrics and health refresh frequency for the dashboard | ||
HEALTH_UPDATE_TICK_SECONDS=1 | ||
METRICS_UPDATE_TICK_SECONDS=5 | ||
|
||
## Enables dev proxy (chisel) into every namespace for proxy / teleport related functionality | ||
KINTO_DEV_PROXY_ENABLED=true | ||
|
||
KINTO_CORE_NAMESPACE=kintohub | ||
|
||
# Kubernetes secret used by kinto builder to push the image into the container registry | ||
# Must be a docker secret - `kubernetes.io/dockerconfigjson` | ||
# Must be in ${KINTO_CORE_NAMESPACE} | ||
KINTO_BUILDER_DOCKER_SECRET=kinto-builder-workflow-docker |
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,56 @@ | ||
package kube | ||
|
||
import ( | ||
"context" | ||
"github.com/kintohub/utils-go/klog" | ||
"github.com/kintoproj/kinto-core/pkg/consts" | ||
v1 "k8s.io/api/core/v1" | ||
k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"time" | ||
) | ||
|
||
func upsertDockerSecret( | ||
kubeClient kubernetes.Interface, dockerSecretName, kintoCoreNamespace, userNamespace string) (*v1.Secret, error) { | ||
defer klog.LogDuration(time.Now(), "upsertDockerSecret") | ||
|
||
// retrieving the kinto build docker secret | ||
kintoBuildDockerSecret, err := kubeClient.CoreV1().Secrets(kintoCoreNamespace).Get( | ||
context.TODO(), dockerSecretName, metav1.GetOptions{}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// retrieving the user docker secret | ||
userDockerSecret, err := kubeClient.CoreV1().Secrets(userNamespace).Get( | ||
context.TODO(), dockerSecretName, metav1.GetOptions{}) | ||
|
||
if k8serrors.IsNotFound(err) { // we create it if not found | ||
userDockerSecret := genDockerSecretFromExistingCoreSecret(kintoBuildDockerSecret, userNamespace) | ||
return kubeClient.CoreV1().Secrets(userNamespace).Create( | ||
context.TODO(), userDockerSecret, metav1.CreateOptions{}) | ||
} else if err != nil { | ||
return nil, err | ||
} | ||
|
||
// we update it if found | ||
userDockerSecret.Data = kintoBuildDockerSecret.Data | ||
return kubeClient.CoreV1().Secrets(userNamespace).Update( | ||
context.TODO(), userDockerSecret, metav1.UpdateOptions{}) | ||
} | ||
|
||
func genDockerSecretFromExistingCoreSecret(kintoBuildDockerSecret *v1.Secret, userNamespace string) *v1.Secret { | ||
return &v1.Secret{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: kintoBuildDockerSecret.Name, | ||
Namespace: userNamespace, | ||
Labels: map[string]string{ | ||
consts.OwnerLabelKey: consts.OwnerLabelValue, | ||
}, | ||
}, | ||
Data: kintoBuildDockerSecret.Data, | ||
Type: v1.SecretTypeDockerConfigJson, | ||
} | ||
} |
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