Skip to content
Snippets Groups Projects
Commit 02a5eb91 authored by garciadav's avatar garciadav Committed by Mark Beierl
Browse files

Update RO charm for the newRO and update bundle


- Add kafka and mongo relations
- Remove ui-k8s from bundle
- Add new RO relations

Change-Id: I9d68cab33dd262408b8023d58e54b0be8dc024c6
Signed-off-by: default avatarDavid Garcia <david.garcia@canonical.com>
Signed-off-by: default avatarbeierlm <mark.beierl@canonical.com>
parent d2d52f71
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,6 @@ applications:
gui-y: 50
nbi-k8s:
charm: "%(prefix)s/nbi-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
storage:
......@@ -97,7 +96,6 @@ applications:
gui-y: -200
ro-k8s:
charm: "%(prefix)s/ro-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
storage:
......@@ -109,19 +107,8 @@ applications:
annotations:
gui-x: -250
gui-y: 300
ui-k8s:
charm: "%(prefix)s/ui-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
options:
mysql_database: lwui
annotations:
gui-x: 250
gui-y: -200
ng-ui:
charm: "%(prefix)s/ng-ui%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
options:
......@@ -134,7 +121,6 @@ applications:
gui-y: 100
lcm-k8s:
charm: "%(prefix)s/lcm-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
storage:
......@@ -153,8 +139,7 @@ applications:
gui-y: 50
mon-k8s:
charm: "%(prefix)s/mon-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
scale: 1
series: kubernetes
storage:
database: 100M
......@@ -175,7 +160,6 @@ applications:
gui-y: 50
pol-k8s:
charm: "%(prefix)s/pol-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
storage:
......@@ -187,7 +171,6 @@ applications:
gui-y: 550
pla:
charm: "%(prefix)s/pla%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
annotations:
......@@ -196,7 +179,7 @@ applications:
prometheus-k8s:
charm: "cs:~charmed-osm/prometheus-k8s"
channel: "stable"
scale: 3
scale: 1
series: kubernetes
storage:
database: 100M
......@@ -251,10 +234,6 @@ relations:
- "mon-k8s:prometheus"
- - "grafana-k8s:prometheus"
- "prometheus-k8s:prometheus"
- - "ui-k8s:mysql"
- "mariadb-k8s:mysql"
- - "ui-k8s:nbi"
- "nbi-k8s:nbi"
- - "prometheus-k8s:prometheus"
- "nbi-k8s:prometheus"
- - "pla:kafka"
......@@ -267,3 +246,7 @@ relations:
- 'mariadb-k8s:mysql'
- - 'keystone:keystone'
- 'nbi-k8s:keystone'
- - "ro-k8s:mongo"
- "mongodb-k8s:mongo"
- - "ro-k8s:kafka"
- "kafka-k8s:kafka"
......@@ -83,7 +83,6 @@ applications:
gui-y: 50
nbi-k8s:
charm: "%(prefix)s/nbi-k8s%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
storage:
......@@ -97,7 +96,6 @@ applications:
gui-y: -200
ro-k8s:
charm: "%(prefix)s/ro-k8s%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
storage:
......@@ -109,19 +107,8 @@ applications:
annotations:
gui-x: -250
gui-y: 300
ui-k8s:
charm: "%(prefix)s/ui-k8s%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
options:
mysql_database: lwui
annotations:
gui-x: 250
gui-y: -200
ng-ui:
charm: "%(prefix)s/ng-ui%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
options:
......@@ -134,7 +121,6 @@ applications:
gui-y: 100
lcm-k8s:
charm: "%(prefix)s/lcm-k8s%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
storage:
......@@ -153,7 +139,6 @@ applications:
gui-y: 50
mon-k8s:
charm: "%(prefix)s/mon-k8s%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
storage:
......@@ -175,7 +160,6 @@ applications:
gui-y: 50
pol-k8s:
charm: "%(prefix)s/pol-k8s%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
storage:
......@@ -187,7 +171,6 @@ applications:
gui-y: 550
pla:
charm: "%(prefix)s/pla%(suffix)s"
channel: "%(channel)s"
scale: 1
series: kubernetes
annotations:
......@@ -217,7 +200,6 @@ applications:
gui-y: 550
keystone:
charm: '%(prefix)s/keystone%(suffix)s'
channel: '%(channel)s'
scale: 1
series: kubernetes
annotations:
......@@ -251,10 +233,6 @@ relations:
- "mon-k8s:prometheus"
- - "grafana-k8s:prometheus"
- "prometheus-k8s:prometheus"
- - "ui-k8s:mysql"
- "mariadb-k8s:mysql"
- - "ui-k8s:nbi"
- "nbi-k8s:nbi"
- - "prometheus-k8s:prometheus"
- "nbi-k8s:prometheus"
- - "pla:kafka"
......@@ -267,3 +245,7 @@ relations:
- 'mariadb-k8s:mysql'
- - 'keystone:keystone'
- 'nbi-k8s:keystone'
- - "ro-k8s:mongo"
- "mongodb-k8s:mongo"
- - "ro-k8s:kafka"
- "kafka-k8s:kafka"
......@@ -16,6 +16,8 @@ includes:
- "layer:status"
- "layer:leadership"
- "layer:osm-common"
- "interface:kafka"
- "interface:mongodb"
- "interface:juju-relation-mysql"
- "interface:osm-ro"
......
......@@ -27,6 +27,10 @@ provides:
requires:
mysql:
interface: mysql
kafka:
interface: kafka
mongo:
interface: mongodb
storage:
log:
type: filesystem
......
......@@ -11,51 +11,96 @@
# 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.
import yaml
from charmhelpers.core.hookenv import log, metadata, config
from charms import layer
from charms.layer.caas_base import pod_spec_set
from charms.osm.k8s import get_service_ip
from charms.reactive import endpoint_from_flag
from charms.reactive import when, when_not, hook
from charms.reactive.flags import set_flag, clear_flag
from charmhelpers.core.hookenv import log, metadata, config
from charms import layer
from charms.osm.k8s import get_service_ip
@hook("upgrade-charm")
@when("leadership.is_leader")
def upgrade():
clear_flag("ro-k8s.configured")
clear_flag("ro-k8s.ready")
@when("config.changed")
@when("leadership.is_leader")
def restart():
clear_flag("ro-k8s.configured")
clear_flag("ro-k8s.ready")
@when_not("mongo.ready")
@when_not("mysql.available")
@when_not("ro-k8s.configured")
@when("leadership.is_leader")
def waiting_for_mysql():
layer.status.waiting("Waiting for mysql to be ready")
layer.status.waiting("Waiting for db to be ready")
clear_flag("ro-k8s.ready")
@when_not("kafka.ready")
@when_not("ro-k8s.configured")
@when("leadership.is_leader")
def waiting_for_kafka():
layer.status.waiting("Waiting for kafka to be ready")
clear_flag("ro-k8s.ready")
@when_not("ro-k8s.ready")
@when("mysql.available")
def ro_k8s_mysql_ready():
set_flag("ro-k8s.ready")
@when_not("ro-k8s.ready")
@when("kafka.ready")
@when("mongo.ready")
def ro_k8s_kafka_mongo_ready():
set_flag("ro-k8s.ready")
@when("ro-k8s.ready")
@when_not("ro-k8s.configured")
@when("leadership.is_leader")
def configure():
layer.status.maintenance("Configuring ro container")
try:
mysql = endpoint_from_flag("mysql.available")
if mysql.host() is not None:
spec = make_pod_spec(
mysql.host(),
mysql.port(),
mysql.user(),
mysql.password(),
mysql.root_password(),
)
kafka = endpoint_from_flag("kafka.ready")
mongo = endpoint_from_flag("mongo.ready")
spec = None
if mysql:
if mysql.host() is not None:
spec = make_pod_spec(
mysql.host(),
mysql.port(),
mysql.user(),
mysql.password(),
mysql.root_password(),
)
elif kafka and mongo:
kafka_units = kafka.kafkas()
kafka_unit = kafka_units[0]
mongo_uri = mongo.connection_string()
if (
mongo_uri
and kafka_unit["host"]
# and kafka_unit["port"]
):
spec = make_pod_spec_new_ro(
kafka_unit["host"],
# kafka_unit["port"],
mongo_uri,
)
if spec:
log("set pod spec:\n{}".format(spec))
pod_spec_set(spec)
layer.status.active("creating container")
......@@ -64,7 +109,7 @@ def configure():
layer.status.blocked("k8s spec failed to deploy: {}".format(e))
@when("mysql.available")
@when("ro-k8s.configured")
@when_not("leadership.is_leader")
def non_leaders_active():
layer.status.active("ready")
......@@ -84,7 +129,8 @@ def send_config():
service_ip = get_service_ip("ro")
if service_ip:
ro.send_connection(
service_ip, get_ro_port(),
service_ip,
get_ro_port(),
)
clear_flag("ro.joined")
except Exception as e:
......@@ -114,15 +160,56 @@ def make_pod_spec(
data = {
"name": md.get("name"),
"mysql_host": mysql_host,
"mysql_port": mysql_port,
"mysql_user": mysql_user,
"mysql_password": mysql_password,
"mysql_root_password": mysql_root_password,
}
data.update(cfg)
spec = yaml.safe_load(pod_spec_template % data)
spec["containers"][0]["config"].update(
{
"RO_DB_HOST": mysql_host,
"RO_DB_PORT": mysql_port,
"RO_DB_NAME": cfg.get("ro_database"),
"RO_DB_USER": mysql_user,
"RO_DB_ROOT_PASSWORD": mysql_root_password,
"RO_DB_PASSWORD": mysql_password,
"RO_DB_OVIM_PASSWORD": mysql_password,
"RO_DB_OVIM_HOST": mysql_host,
"RO_DB_OVIM_PORT": mysql_port,
"RO_DB_OVIM_USER": mysql_user,
"RO_DB_OVIM_ROOT_PASSWORD": mysql_root_password,
"RO_DB_OVIM_NAME": cfg.get("vim_database"),
}
)
return spec
def make_pod_spec_new_ro(kafka_host, mongodb_uri):
"""Make pod specification for Kubernetes
Args:
kafka_host (str): Kafka host
mongodb_uri (str): Mongodb URI
Returns:
pod_spec: Pod specification for Kubernetes
"""
with open("reactive/spec_template.yaml") as spec_file:
pod_spec_template = spec_file.read()
md = metadata()
cfg = config()
return pod_spec_template % data
data = {
"name": md.get("name"),
}
data.update(cfg)
spec = yaml.safe_load(pod_spec_template % data)
spec["containers"][0]["config"].update(
{
"OSMRO_DATABASE_URI": mongodb_uri,
"OSMRO_MESSAGE_HOST": kafka_host,
}
)
return spec
def get_ro_port():
......
......@@ -21,14 +21,6 @@ containers:
username: %(image_username)s
password: %(image_password)s
kubernetes:
readinessProbe:
httpGet:
path: /openmano/tenants
port: %(advertised-port)s
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
livenessProbe:
tcpSocket:
port: %(advertised-port)s
......@@ -42,17 +34,4 @@ containers:
protocol: TCP
config:
ALLOW_ANONYMOUS_LOGIN: 'yes'
RO_DB_HOST: %(mysql_host)s
RO_DB_PORT: %(mysql_port)s
RO_DB_NAME: %(ro_database)s
RO_DB_USER: %(mysql_user)s
RO_DB_ROOT_PASSWORD: %(mysql_root_password)s
RO_DB_PASSWORD: %(mysql_password)s
RO_DB_OVIM_PASSWORD: %(mysql_password)s
RO_DB_OVIM_HOST: %(mysql_host)s
RO_DB_OVIM_PORT: %(mysql_port)s
RO_DB_OVIM_USER: %(mysql_user)s
RO_DB_OVIM_ROOT_PASSWORD: %(mysql_root_password)s
RO_DB_OVIM_NAME: %(vim_database)s
OPENMANO_TENANT: %(OPENMANO_TENANT)s
......@@ -36,8 +36,10 @@ whitelist_externals = git
mv
commands =
rm -rf release
rm -rf ../interfaces/mongodb
rm -rf ../interfaces/juju-relation-mysql
rm -rf /tmp/canonical-osm
git clone https://git.launchpad.net/interface-mongodb ../interfaces/mongodb
git clone https://git.launchpad.net/canonical-osm/ /tmp/canonical-osm
mv /tmp/canonical-osm/charms/interfaces/juju-relation-mysql ../interfaces/juju-relation-mysql
charm build . --build-dir /tmp
......
......@@ -275,22 +275,16 @@ function deploy_charmed_osm(){
juju expose prometheus-k8s
wait_for_port prometheus-k8s 3
# Expose UI
juju config ui-k8s juju-external-hostname=osm.${API_SERVER}.xip.io
juju expose ui-k8s
wait_for_port ui-k8s 4
# Apply annotations
sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/backend-protocol=HTTPS -n osm -l juju-app=nbi-k8s"
sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=nbi-k8s"
sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ng-ui"
sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ui-k8s"
}
function check_osm_deployed() {
TIME_TO_WAIT=600
start_time="$(date -u +%s)"
total_service_count=15
total_service_count=14
previous_count=0
while true
do
......@@ -381,9 +375,6 @@ applications:
pol-k8s:
options:
image: ${REGISTRY_URL}opensourcemano/pol:$TAG ${REGISTRY_CREDENTIALS}
ui-k8s:
options:
image: ${REGISTRY_URL}opensourcemano/light-ui:$TAG ${REGISTRY_CREDENTIALS}
pla:
options:
image: ${REGISTRY_URL}opensourcemano/pla:$TAG ${REGISTRY_CREDENTIALS}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment