Skip to content

Commit

Permalink
Hard code k8s api endpoint
Browse files Browse the repository at this point in the history
Hard code K8S API endpoints in all cases becuase netplugin is not
able to handle the service ip correctly for daemonset
  • Loading branch information
Wei Tie committed Jan 16, 2018
1 parent ad6aae1 commit 056f0a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion install/k8s/cluster/k8smaster_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -n "$CONTIV_TEST" ]; then
else
# update to use released version
cd /opt/gopath/src/github.com/contiv/netplugin/install/k8s/contiv/
./contiv-compose use-release -v $(cat /opt/gopath/src/github.com/contiv/netplugin/version/CURRENT_VERSION) ./contiv-base.yaml > /shared/contiv.yaml
./contiv-compose use-release --k8s-api https://$2:$3 -v $(cat /opt/gopath/src/github.com/contiv/netplugin/version/CURRENT_VERSION) ./contiv-base.yaml > /shared/contiv.yaml
fi

kubectl apply -f /shared/contiv.yaml
30 changes: 21 additions & 9 deletions install/k8s/contiv/contiv-compose
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import argparse
from contextlib import contextmanager
import os
import sys
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
import yaml


Expand Down Expand Up @@ -64,13 +68,6 @@ class ContivComposer(object):
'hostPath': {'path': '/var/log/contiv'}
})

if self._is_resource(resource, 'ConfigMap', 'contiv-config',
'kube-system'):
if args['k8s_api'] is not None:
k8s_config = resource['data']['contiv_k8s_config']
resource['data']['contiv_k8s_config'] = k8s_config.replace(
'https://__KUBERNETES_SERVICE_HOST__:__KUBERNETES_SERVICE_PORT__',
args['k8s_api'])

def add_prometheus(self, resource, args):
if (self._is_resource(resource, 'DaemonSet', 'contiv-netplugin',
Expand Down Expand Up @@ -178,6 +175,21 @@ class ContivComposer(object):
for resource in data:
func(resource, args)
self._update_images(resource, args)
# update k8s api because netplugin doesn't work with service vip
# TODO: fix it in netplugin
self._update_k8s_api_config(resource, args)

def _update_k8s_api_config(self, resource, args):
if self._is_resource(resource, 'ConfigMap', 'contiv-config',
'kube-system'):
if args['k8s_api'] is not None:
k8s_config = resource['data']['contiv_k8s_config']

resource['data']['contiv_k8s_config'] = k8s_config.replace(
'https://__KUBERNETES_SERVICE_HOST__:__KUBERNETES_SERVICE_PORT__',
args['k8s_api'])
resource['data']['contiv_etcd'] = "http://%s:6666" % urlparse(
args['k8s_api']).hostname

def _is_resource(self, resource, kind, name, namespace=None):
return (resource['kind'] == kind and
Expand Down Expand Up @@ -249,6 +261,7 @@ class ContivComposer(object):


def _add_common_args(parser):
parser.add_argument('--k8s-api', help='k8s api endpoint')
parser.add_argument('-i',
'--in-place',
action='store_true',
Expand Down Expand Up @@ -284,7 +297,7 @@ def create_cli_args():
description="Add system test required updates")
_add_common_args(systest_parser)
_add_image_args(systest_parser)
systest_parser.add_argument('--k8s-api', help='k8s api endpoint')


# add prometheus
prometheus_parser = subclis.add_parser(
Expand Down Expand Up @@ -331,7 +344,6 @@ def create_cli_args():
'--version',
default='latest',
help='the release version to use')

return parser


Expand Down

0 comments on commit 056f0a5

Please sign in to comment.