GKEのkubernetesでredisインスタンスとクラスタを結合するチュートリアル通りにEXTERNAL-IPでアクセスしたのですが、下のようなエラーが出てしまいます
$ curl http://35.200.67.203 >>> curl: (7) Failed to connect to 35.200.67.203 port 80: Connection refused
ファイルは下のような構成と内容になってます。おそらくserviceを定義しているロードバランサに問題があるかと思うのですが、理由がわかりません。ご教授お願いします
ファイル一覧
app.yaml Dockerfile main.py redis_lb.yaml redis_pod.yaml requirements.txt
yaml
1# redis_lb_pod.yaml 2apiVersion: extensions/v1beta1 3kind: Deployment 4metadata: 5 name: visit-counter 6 labels: 7 app: visit-counter 8spec: 9 replicas: 1 10 template: 11 metadata: 12 labels: 13 app: visit-counter 14 spec: 15 containers: 16 - name: visit-counter 17 image: "gcr.io/buyma-dev/visit-counter:v1" 18 env: 19 - name: REDISHOST 20 valueFrom: 21 configMapKeyRef: 22 name: redishost 23 key: REDISHOST 24 ports: 25 - name: http 26 containerPort: 8080 27--- 28apiVersion: v1 29kind: Service 30metadata: 31 name: visit-counter 32spec: 33 type: LoadBalancer 34 selector: 35 app: visit-counter 36 ports: 37 - port: 80 38 targetPort: 8080 39 protocol: TCP 40
txt
1# Dockerfile 2FROM gcr.io/google_appengine/python 3 4 5RUN virtualenv -p python3.4 /env 6 7ENV VIRTUAL_ENV /env 8ENV PATH /env/bin:$PATH 9 10# Note: REDISHOST value here is only used for local testing 11# See README.md on how to inject environment variable as ConfigMap on GKE 12ENV REDISHOST 10.0.0.3 13ENV REDISPORT 6379 14 15# Install dependencies. 16ADD requirements.txt /app/requirements.txt 17RUN pip install -r /app/requirements.txt 18 19# Add application code. 20ADD . /app 21 22EXPOSE 8080 23 24CMD ["gunicorn", "-b", "0.0.0.0:8080", "main:app"] 25 26 27 28 29 30# requirements.txt 31Flask==1.0.2 32gunicorn==19.9.0 33redis==3.0.1
python
1# main.py 2import logging 3import os 4 5from flask import Flask 6import redis 7 8app = Flask(__name__) 9 10redis_client = redis.StrictRedis(host='localhost', port=6379, db=0) 11 12@app.route('/') 13def index(): 14 value = redis_client.incr('counter', 1) 15 return 'Visitor number: {}'.format(value) 16 17 18@app.errorhandler(500) 19def server_error(e): 20 logging.exception('An error occurred during a request.') 21 return """ 22 An internal error occurred: <pre>{}</pre> 23 See logs for full stacktrace. 24 """.format(e), 500 25 26 27if __name__ == '__main__': 28 app.run(host='0.0.0.0')
yaml
1# app.yaml 2runtime: python 3env: flex 4entrypoint: gunicorn -b :$PORT main:app 5 6runtime_config: 7 python_version: 3 8 9# update with Redis instance host IP, port 10env_variables: 11 REDISHOST: 10.0.0.3 12 REDISPORT: 6379 13 14# update with Redis instance network name 15network: 16 name: default
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。