-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
3,523 additions
and
147 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
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,30 @@ | ||
# Copyright (c) 2023 VEXXHOST, Inc. | ||
# | ||
# 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. | ||
|
||
from oslo_config import cfg | ||
from oslo_log import log as logging | ||
|
||
from magnum_cluster_api import service | ||
from magnum_cluster_api.proxy import manager | ||
|
||
CONF = cfg.CONF | ||
|
||
|
||
def main(): | ||
logging.register_options(CONF) | ||
logging.setup(CONF, "magnum-cluster-api-proxy") | ||
|
||
server = service.Service(manager=manager.ProxyManager) | ||
service.serve(server) | ||
service.wait() |
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,37 @@ | ||
# Copyright (c) 2023 VEXXHOST, Inc. | ||
# | ||
# 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. | ||
|
||
from magnum.conductor import k8s_api as k8s | ||
from magnum.drivers.common import k8s_monitor | ||
from oslo_log import log as logging | ||
|
||
from magnum_cluster_api import utils | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class Monitor(k8s_monitor.K8sMonitor): | ||
def poll_health_status(self): | ||
# NOTE(mnaser): We override the `api_address` for the cluster if it's | ||
# an isolated cluster so we can go through the proxy. | ||
if utils.get_cluster_floating_ip_disabled(self.cluster): | ||
api_address = f"https://{self.cluster.stack_id}.magnum-system:6443" | ||
self.cluster.api_address = api_address | ||
LOG.debug("Overriding cluster api_address to %s", api_address) | ||
|
||
k8s_api = k8s.KubernetesAPI(self.context, self.cluster) | ||
status, reason = self._poll_health_status(k8s_api) | ||
|
||
self.data["health_status"] = status | ||
self.data["health_status_reason"] = reason |
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,22 @@ | ||
# Copyright (c) 2023 VEXXHOST, Inc. | ||
# | ||
# 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. | ||
|
||
from oslo_privsep import capabilities, priv_context | ||
|
||
haproxy_pctxt = priv_context.PrivContext( | ||
__name__, | ||
cfg_section="magnum_cluster_api_haproxy", | ||
pypath=__name__ + ".haproxy_pctxt", | ||
capabilities=[capabilities.CAP_NET_ADMIN], | ||
) |
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,47 @@ | ||
# Copyright (c) 2023 VEXXHOST, Inc. | ||
# | ||
# 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. | ||
|
||
import os | ||
import signal | ||
import subprocess | ||
|
||
from oslo_log import log as logging | ||
|
||
import magnum_cluster_api.privsep | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
@magnum_cluster_api.privsep.haproxy_pctxt.entrypoint | ||
def start(config_file): | ||
proc = subprocess.Popen(["haproxy", "-f", config_file]) | ||
|
||
try: | ||
retcode = proc.wait(timeout=5) | ||
if retcode != 0: | ||
LOG.error("HAproxy failed to start") | ||
except subprocess.TimeoutExpired: | ||
LOG.info("HAproxy started successfully") | ||
|
||
return proc.pid | ||
|
||
|
||
@magnum_cluster_api.privsep.haproxy_pctxt.entrypoint | ||
def reload(): | ||
"""Reload HAproxy configuration""" | ||
|
||
with open("/var/run/haproxy.pid", "r") as fd: | ||
pid = int(fd.read().strip()) | ||
|
||
os.kill(pid, signal.SIGUSR2) |
Oops, something went wrong.