Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
02cc24e8
Commit
02cc24e8
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Added file to refresh TFS runtime env_vars script.
parent
70662d96
No related branches found
No related tags found
1 merge request
!54
Release 2.0.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
update_tfs_runtime_env_vars.sh
+67
-0
67 additions, 0 deletions
update_tfs_runtime_env_vars.sh
with
67 additions
and
0 deletions
update_tfs_runtime_env_vars.sh
0 → 100755
+
67
−
0
View file @
02cc24e8
#!/bin/bash
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
########################################################################################################################
# Read deployment settings
########################################################################################################################
# If not already set, set the list of components you want to build images for, and deploy.
# By default, only basic components are deployed
export
TFS_COMPONENTS
=
${
TFS_COMPONENTS
:-
"context device monitoring service compute webui"
}
# If not already set, set the name of the Kubernetes namespace to deploy to.
export
TFS_K8S_NAMESPACE
=
${
TFS_K8S_NAMESPACE
:-
"tfs"
}
########################################################################################################################
# Automated steps start here
########################################################################################################################
echo
"Deploying components and collecting environment variables..."
ENV_VARS_SCRIPT
=
tfs_runtime_env_vars.sh
echo
"# Environment variables for TeraFlowSDN deployment"
>
$ENV_VARS_SCRIPT
PYTHONPATH
=
$(
pwd
)
/src
echo
"export PYTHONPATH=
${
PYTHONPATH
}
"
>>
$ENV_VARS_SCRIPT
for
COMPONENT
in
$TFS_COMPONENTS
;
do
echo
" Collecting env-vars for '
$COMPONENT
' component..."
SERVICE_DATA
=
$(
kubectl get service
${
COMPONENT
}
service
--namespace
$TFS_K8S_NAMESPACE
-o
json
)
if
[
-z
"
${
SERVICE_DATA
}
"
]
;
then continue
;
fi
# Env vars for service's host address
SERVICE_HOST
=
$(
echo
${
SERVICE_DATA
}
| jq
-r
'.spec.clusterIP'
)
if
[
-z
"
${
SERVICE_HOST
}
"
]
;
then continue
;
fi
ENVVAR_HOST
=
$(
echo
"
${
COMPONENT
}
service_SERVICE_HOST"
|
tr
'[:lower:]'
'[:upper:]'
)
echo
"export
${
ENVVAR_HOST
}
=
${
SERVICE_HOST
}
"
>>
$ENV_VARS_SCRIPT
# Env vars for service's 'grpc' port (if any)
SERVICE_PORT_GRPC
=
$(
echo
${
SERVICE_DATA
}
| jq
-r
'.spec.ports[] | select(.name=="grpc") | .port'
)
if
[
-n
"
${
SERVICE_PORT_GRPC
}
"
]
;
then
ENVVAR_PORT_GRPC
=
$(
echo
"
${
COMPONENT
}
service_SERVICE_PORT_GRPC"
|
tr
'[:lower:]'
'[:upper:]'
)
echo
"export
${
ENVVAR_PORT_GRPC
}
=
${
SERVICE_PORT_GRPC
}
"
>>
$ENV_VARS_SCRIPT
fi
# Env vars for service's 'http' port (if any)
SERVICE_PORT_HTTP
=
$(
echo
${
SERVICE_DATA
}
| jq
-r
'.spec.ports[] | select(.name=="http") | .port'
)
if
[
-n
"
${
SERVICE_PORT_HTTP
}
"
]
;
then
ENVVAR_PORT_HTTP
=
$(
echo
"
${
COMPONENT
}
service_SERVICE_PORT_HTTP"
|
tr
'[:lower:]'
'[:upper:]'
)
echo
"export
${
ENVVAR_PORT_HTTP
}
=
${
SERVICE_PORT_HTTP
}
"
>>
$ENV_VARS_SCRIPT
fi
printf
"
\n
"
done
echo
"Done!"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment