I’ve gotten the redis service up and running on the shared runners by adding it to my task in .gitlab-ci.yml
py27:
stage: run
image: python:2.7
script:
- mkdir -p build/coverage
- pip install -r requirements.txt
- pytest --color=no --verbose --ignore=almanac/migrations --cov=almanac --cov-config=.coveragerc tests
- cp .coverage build/coverage/py27.coverage
services:
- redis:latest
artifacts:
paths:
- build/*
However, when the task is ran by the kubernetes cluster (GKE) it cannot find the redis service/name:
almanac/weather/dkmetar.py:188: in Metar
rval = r.get(redis_key)
/usr/local/lib/python2.7/site-packages/redis/client.py:1264: in get
return self.execute_command('GET', name)
/usr/local/lib/python2.7/site-packages/redis/client.py:772: in execute_command
connection = pool.get_connection(command_name, **options)
/usr/local/lib/python2.7/site-packages/redis/connection.py:994: in get_connection
connection.connect()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Connection<host=redis,port=6379,db=0>
def connect(self):
"Connects to the Redis server if not already connected"
if self._sock:
return
try:
sock = self._connect()
except socket.timeout:
raise TimeoutError("Timeout connecting to server")
except socket.error:
e = sys.exc_info()[1]
> raise ConnectionError(self._error_message(e))
E ConnectionError: Error -2 connecting to redis:6379. Name or service not known.
/usr/local/lib/python2.7/site-packages/redis/connection.py:497: ConnectionError
I only have about 3 weeks experience with gitlab, docker, and kubernetes; so I’m guessing I’ve missed something obvious…?