Skip to content

Commit

Permalink
Merge pull request #5 from microsoft/coresvc-registry-docker
Browse files Browse the repository at this point in the history
enabling core_registry start and stop in docker
  • Loading branch information
bigtallcampbell authored Jun 10, 2024
2 parents 731bcbb + 8f439e0 commit a3601fc
Show file tree
Hide file tree
Showing 22 changed files with 706 additions and 31 deletions.
Empty file modified .devcontainer/features/spacefx-dev/install.sh
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=SC2154
Empty file modified build/build_containerImage.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions certs/registry/registry.spacefx.local.ssl.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"*.registry.spacefx.local:5000",
"registry.spacefx.local:5000",
"localhost:5000",
"core-registry.core.svc.cluster.local",
"core-registry.core.svc.cluster.local:5000"
"coresvc-registry.coresvc.svc.cluster.local",
"coresvc-registry.coresvc.svc.cluster.local:5000"
],
"key": {
"algo": "rsa",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
spec:
type: NodePort
ports:
- name: core-registry
- name: {{ $serviceValues.repository }}
port: {{ $serviceValues.targetPort }}
targetPort: {{ $serviceValues.targetPort }}
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:
version: v1
metadata:
- name: host
value: "amqp://{{ $serviceValues.appName }}.core:5672"
value: "amqp://{{ $serviceValues.appName }}.coresvc:5672"
- name: autoAck
value: true
- name: deliveryMode
Expand Down
24 changes: 12 additions & 12 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ global:
resourceScavengerTimingMS: 30000
containerCommand: dotnet
containerRegistry: registry.spacefx.local:5000
containerRegistryInternal: core-registry.core.svc.cluster.local:5000
containerRegistryInternal: coresvc-registry.coresvc.svc.cluster.local:5000
dapr:
logLevel: debug
debugShim:
Expand Down Expand Up @@ -79,7 +79,7 @@ global:
namespaces:
enabled: false
list:
- namespace: core
- namespace: coresvc
- namespace: hostsvc
- namespace: payload-app
- namespace: platformsvc
Expand All @@ -102,7 +102,7 @@ subcharts:
services:
core:
buildservice:
serviceNamespace: core
serviceNamespace: coresvc
enabled: false
targetService:
appName: exampleapp
Expand All @@ -113,21 +113,21 @@ services:
dockerFile: Dockerfile.svc
contextDir: build/dotnet
registry:
appName: core-registry
appName: coresvc-registry
containerCommand:
- /usr/bin/registry
containerArgs:
- serve
- /etc/docker/registry/config.yml
serviceNamespace: core
serviceNamespace: coresvc
prod:
enabled: false
hasBase: false
dev:
enabled: false
hasBase: false
enabled: false
repository: core-registry
repository: coresvc-registry
targetPort: 5000
tlsCertificate: /certs/registry.spacefx.local.crt
tlsKey: /certs/registry.spacefx.local.key
Expand All @@ -139,23 +139,23 @@ services:
limit: 1000m
request: 10m
switchboard:
appName: core-switchboard
serviceNamespace: core
appName: coresvc-switchboard
serviceNamespace: coresvc
prod:
enabled: true
hasBase: false
dev:
enabled: true
hasBase: false
enabled: false
repository: core-switchboard
repository: coresvc-switchboard
fileserver:
appName: core-fileserver
appName: coresvc-fileserver
logLevel: info
maximumNumberOfLogs: 15
pollingTimeSecs: 5
repository: core-fileserver
serviceNamespace: core
repository: coresvc-fileserver
serviceNamespace: coresvc
prod:
enabled: true
hasBase: false
Expand Down
5 changes: 3 additions & 2 deletions modules/load_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ source "${MODULE_DIR}/m_40_regctl_config.sh"
source "${MODULE_DIR}/m_45_emulator.sh"
source "${MODULE_DIR}/m_50_spacefx-config.sh"
source "${MODULE_DIR}/m_60_container_registries.sh"
source "${MODULE_DIR}/m_80_core_registry_hosts.sh"
source "${MODULE_DIR}/m_70_certificates.sh"
source "${MODULE_DIR}/m_80_coresvc_registry_hosts.sh"


############################################################
Expand Down Expand Up @@ -86,4 +87,4 @@ _app_prereqs_validate
_generate_spacefx_config_json

_update_regctl_config
_check_for_core_registry_hosts_entry
_check_for_coresvc_registry_hosts_entry
Empty file modified modules/m_10_is_cmd_available.sh
100644 → 100755
Empty file.
Empty file modified modules/m_25_calculate_host_architecture.sh
100644 → 100755
Empty file.
Empty file modified modules/m_30_app_prereqs.sh
100644 → 100755
Empty file.
Empty file modified modules/m_40_regctl_config.sh
100644 → 100755
Empty file.
Empty file modified modules/m_45_emulator.sh
100644 → 100755
Empty file.
Empty file modified modules/m_50_spacefx-config.sh
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion modules/m_5_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function run_a_script() {
fi

local log_enabled=true
local log_results_enabled=true
local ignore_error=false
local run_in_background=false
local returnResult=""
Expand All @@ -59,6 +60,9 @@ function run_a_script() {
--disable_log)
log_enabled=false
;;
--no_log_results)
log_results_enabled=false
;;
--background)
run_in_background=true
;;
Expand Down Expand Up @@ -132,7 +136,7 @@ function run_a_script() {
if [[ -n ${__returnVar} ]]; then
returnResult=$(<"$script_temp_file")
eval $__returnVar="'$returnResult'"
[[ "${log_enabled}" == true ]] && debug_log "...'${run_cmd}' Result: ${returnResult}"
[[ "${log_enabled}" == true ]] && [[ "${log_results_enabled}" == true ]] && debug_log "...'${run_cmd}' Result: ${returnResult}"
fi

if [[ $RETURN_CODE -gt 0 ]] && [[ "${ignore_error}" == false ]]; then
Expand Down
114 changes: 103 additions & 11 deletions modules/m_60_container_registries.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,108 @@
#!/bin/bash

############################################################
# Find the first container registry with push access enabled
# Check if we need to add a prefix to the repo based on the supplied container registry
############################################################
function get_registry_with_push_access() {
local return_result_var=$1
if [[ -z "${return_result_var}" ]]; then
exit_with_error "Please supply a return variable name for results"
function check_for_repo_prefix(){

local registry=""
local repo=""
local returnResult=""

while [[ "$#" -gt 0 ]]; do
case $1 in
--registry)
shift
registry=$1
;;
--repo)
shift
repo=$1
;;
--result)
shift
returnResult=$1
;;
*)
echo "Unknown parameter '$1'"
exit 1
;;
esac
shift
done

if [[ -z "${container_registry}" ]] || [[ -z "${repo}" ]] || [[ -z "${returnResult}" ]]; then
exit_with_error "Missing a parameter. Please use function like check_for_repo_prefix --registry \"registry\" --repo \"repo\" --result \"returnResult\". Please supply all parameters."
fi
run_a_script "jq -r '.config.containerRegistries[] | select(.push_enabled == true) | .url' ${SPACEFX_DIR}/tmp/config/spacefx-config.json | head -n 1" container_registry_with_push_access --ignore_error --disable_log
eval "$return_result_var='$container_registry_with_push_access'"

if [[ ! -f "${SPACEFX_DIR}/tmp/config/spacefx-config.json" ]]; then
warn_log "Configuration file not found. Running '_generate_spacefx_config_json' to generate it."
_generate_spacefx_config_json
fi

# Check if our destination repo has a repositoryPrefix
run_a_script "jq -r '.config.containerRegistries[] | select(.url == \"${registry}\") | if (has(\"repositoryPrefix\")) then .repositoryPrefix else \"\" end' ${SPACEFX_DIR}/tmp/config/spacefx-config.json" repo_prefix

if [[ -n "${repo_prefix}" ]]; then
# Check if we already prefixed the repo name
if [[ "${repo}" == "$repo_prefix"* ]]; then
debug_log "Repository Prefix '${repo_prefix}' for ${registry} is already applied to '${repo}'. Nothing to do"
eval "$returnResult='${repo}'"
else
debug_log "Repository Prefix '${repo_prefix}' found for ${registry}. Returning '${repo_prefix}/${repo}'"
eval "$returnResult='${repo_prefix}/${repo}'"
fi
else
debug_log "No Repository Prefix found for ${registry}. Returning '${repo}'"
eval "$returnResult='${repo}'"
fi

}


############################################################
# Get the container tag value based on the channel we're using
############################################################
function calculate_tag_from_channel() {

local tag=""
local returnResult=""
local return_tag=""

while [[ "$#" -gt 0 ]]; do
case $1 in
--tag)
shift
tag=$1
;;
--result)
shift
returnResult=$1
;;
*)
echo "Unknown parameter '$1'"
exit 1
;;
esac
shift
done

if [[ -z "${tag}" ]] || [[ -z "${returnResult}" ]]; then
exit_with_error "Missing a parameter. Please use function like calculate_tag_from_channel --tag \"tag\" --result \"result\". Please supply all parameters."
fi

if [[ "${SPACEFX_CHANNEL}" == "nightly" ]]; then
return_tag="${tag}-nightly"
fi

if [[ "${SPACEFX_CHANNEL}" == "rc" ]]; then
return_tag="${tag}-rc"
fi

eval "$returnResult='$return_tag'"
}


############################################################
# Find the first container registry with push access enabled
############################################################
Expand Down Expand Up @@ -43,13 +134,14 @@ function find_registry_for_image(){
for row in $container_registries; do
parse_json_line --json "${row}" --property ".url" --result container_registry

info_log "Checking container registry '${container_registry}' for image '${container_image}'..."
check_for_repo_prefix --registry "${container_registry}" --repo "${container_image}" --result _find_registry_for_image_repo

info_log "Checking container registry '${container_registry}' for image '${_find_registry_for_image_repo}'..."

login_to_container_registry ${container_registry}
run_a_script "regctl image manifest ${container_registry}/${container_image}" --ignore_error --disable_log
run_a_script "regctl image manifest ${container_registry}/${_find_registry_for_image_repo}" --ignore_error --disable_log

if [[ "${RETURN_CODE}" -eq 0 ]]; then
info_log "...image '${container_image}' FOUND in container registry '${container_registry}'"
info_log "...image '${container_image}' FOUND in container registry '${container_registry}' as '${_find_registry_for_image_repo}'"
REGISTRY_IMAGE_NAME="${container_registry}"
break;
else
Expand Down
Loading

0 comments on commit a3601fc

Please sign in to comment.