Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A proposed implementation of DiscoveryInfo in an Apache Aurora Job.
#
# 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.
#
VISIBILITY_FRAMEWORK = 0
VISIBILITY_CLUSTER = 1
VISIBILITY_EXTERNAL = 2
PROTOCOL_TCP = "TCP"
PROTOCOL_UDP = "UDP"
PROTOCOL_TLS = "TLS"
PROTOCOL_SSL = "SSL"
PROTOCOL_HTTP = "HTTP"
PROTOCOL_HTTPS = "HTTPS"
hello = Process(
name='hello',
cmdline="""
while true; do
echo hello world
sleep 10
done
""")
task = SequentialTask(
processes=[hello],
resources=Resources(cpu=1.0, ram=128 * MB, disk=128 * MB))
jobs = [
Service(
task=task,
cluster='devcluster',
role='www-data',
environment='prod',
name='hello',
announce=Announcer(
primary_port='http',
portmap={
'http': 'aurora',
},
),
discovery=DiscoveryInfo(
# This would allow job to control its visibility in the Mesos DiscoveryInfo and allow consumers of
# this information make an informed decscion regarding its exposure.
visibility=VISIBILITY_EXTERNAL,
# Optional: if not provided it should provide the defaults currently provided which is the inverse
# task name: job.env.role
name="my.little.snowflake",
# Optional: The default would be the `environment` value but allow for customization
environment="devel",
# Optional: Default to the Aurora Cluster name, but allow the job to set this to a desired value
location="dc1",
# Optional: Currently not populated however allow the job to declare this in a sane manner to drive
# service discovery options.
version="1.0.1",
# Optional: Default it would operate the same as current and default ALL ports to TCP, however because
# this is often a flawed reflection of services there should be a means by which to map port names in the
# TaskConfig to sane protocols so consumers of information may make reasonable presumptions of how to
# consume the exposed services
ports={"http": PROTOCOL_HTTP, 'https': PROTOCOL_HTTPS},
# Optional: Currently Not used, however allow a job to declare lables that are for service discovery that
# are unrelated to the task labels.
labels=[
Metadata(key="meta", value="data")
]
)
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.