目前 kubernetes 还没有提供“随机端口”的特性,所以实现起来比较麻烦。
下面前 2 种方案主要考虑的场景是 dubbo 运行在 kubernetes 集群中,但是也希望 kubernetes 集群“外”的应用也能使用这些 dubbo 服务。
实现原理:
- dubbo 已经提供了 2 个环境变量: DUBBO_IP_TO_REGISTRY、DUBBO_PORT_TO_REGISTRY 分别表示服务注册到注册中心的 IP 和 PORT。
import asyncio | |
import threading | |
import random | |
def thr(i): | |
# we need to create a new loop for the thread, and set it as the 'default' | |
# loop that will be returned by calls to asyncio.get_event_loop() from this | |
# thread. | |
loop = asyncio.new_event_loop() |
<scheme name="One Dark" version="142" parent_scheme="Default"> | |
<option name="LINE_SPACING" value="1.0" /> | |
<option name="EDITOR_FONT_SIZE" value="12" /> | |
<option name="CONSOLE_FONT_NAME" value="Monospaced" /> | |
<option name="EDITOR_FONT_NAME" value="Menlo" /> | |
<colors> | |
<option name="ADDED_LINES_COLOR" value="abb2bf" /> | |
<option name="ANNOTATIONS_COLOR" value="ffffff" /> | |
<option name="ANNOTATIONS_MERGED_COLOR" value="ffffff" /> | |
<option name="CARET_COLOR" value="61afef" /> |
FROM zokeber/centos:latest | |
MAINTAINER Mark Kelly <[email protected]> | |
RUN touch /var/lib/rpm/* | |
RUN yum install -y deltarpm; yum clean all | |
RUN yum install -y sudo; yum clean all | |
# Set versions. Check http://openresty.org for latest version and bundled version of nginx. | |
ENV OPENRESTY_VERSION 1.9.3.1 | |
ENV NGINX_VERSION 1.9.3 |
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ nano ~/.zshrc
path=('/path/to/depot_tools' $path)
" Cycle metasyntactic variables | |
function! s:CycleMetasyntacticVariables(num) | |
if type(a:num) != type(0) | |
return | |
endif | |
let vars = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'] | |
let cvar = expand('<cword>') | |
let i = index(vars, cvar) |
# | |
# A CORS (Cross-Origin Resouce Sharing) config for nginx | |
# | |
# == Purpose | |
# | |
# This nginx configuration enables CORS requests in the following way: | |
# - enables CORS just for origins on a whitelist specified by a regular expression | |
# - CORS preflight request (OPTIONS) are responded immediately | |
# - Access-Control-Allow-Credentials=true for GET and POST requests |
# | |
# Slightly tighter CORS config for nginx | |
# | |
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs | |
# | |
# Despite the W3C guidance suggesting that a list of origins can be passed as part of | |
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox) | |
# don't seem to play nicely with this. | |
# |