现在,我正在使用helm使用values.yaml
文件中的值替换文件中的变量,以创建一个ConfigMap,该ConfigMap适用于间隔正确的条目。
我遇到以下问题:
CELERY_BROKER_URL = "amqp://admin:admin@{{ .Values.env.RABBITMQ_HOST }}:5672/"
运行helm install
:时导致此错误
Error: render error in "mynamespace-nonprod-chart/templates/configmap.yaml": template: mynamespace-nonprod-chart/templates/configmap.yaml:10:4: executing "mynamespace-nonprod-chart/templates/configmap.yaml" at <tpl (.Files.Glob "conf/*").AsConfig .>: error calling tpl: Error during tpl function execution for "settings.py: "\"\"\"\nDjango settings for imagegateway project.\n\nGenerated by 'django-adminn startproject' using Django 1.11.3.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/1.11/topics/settings/\n\nForn the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/1.11/ref/settings/\n\"\"\"\n\nimportn os\n\nfrom kombu import Exchange, Queue\n\n\n# Image Config\nIMAGE_ASPECT_RATIOn = (4,3) # 4:3\nMLS_BASE_URL = 'http://www.torontomls.net/MLSMULTIPHOTOS/FULL'\nCALLBACK_KEYn = 'SECRET'\n\nBASE_URL = 'https://media-dev.mydomain.ca'\n\n#n Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIRn = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\nMAXIMUM_HASH_DISTANCEn = 5\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEYn = 'mysecretkey'\n\n# SECURITY WARNING: don't run with debug turned on in production!\n#n DEBUG = False\nDEBUG = True\n\nALLOWED_HOSTS = ['0.0.0.0', '*']\n\n# Celery\n\n#n {{ .Values.env.INGRESS_CONTROLLER_ENDPOINT }} TEST this\nCELERY_BROKER_URL = \"amqp://admin:xWQ7ye7YotNif@{{n .Values.env.RABBITMQ_HOST }}:5672/\"\nCELERY_ACCEPT_CONTENT = ['application/json']\nCELERY_TASK_SERIALIZERn = 'json'\nCELERY_RESULT_SERIALIZER = 'json'\nCELERY_RESULT_BACKEND = 'redis://dummyuser:R3dis0nEKS!@redis-imagegateway-dev-shared-headless'\nCELERY_RESULT_PERSISTENTn = False\nCELERY_TIMEZONE = 'Canada/Eastern'\nCELERY_ALWAYS_EAGER = False \nCELERY_ACKS_LATEn = True \nCELERYD_PREFETCH_MULTIPLIER = 1\nCELERY_TASK_PUBLISH_RETRY = True \nCELERY_DISABLE_RATE_LIMITSn = False\nCELERY_IMPORTS = ('garden.tasks', 'keeper.tasks', 'tourist.tasks',)\nCELERY_DEFAULT_QUEUEn = 'default'\nCELERY_DEFAULT_EXCHANGE_TYPE = 'topic'\nCELERY_DEFAULT_ROUTING_KEYn = 'default'\nCELERYD_TASK_SOFT_TIME_LIMIT = 60\n\nCELERY_TASK_QUEUES = (\n Queue('tourist',n Exchange('tourist'), routing_key='tourist.#', queue_arguments={'x-max-priority':n 1}),\n Queue('default', Exchange('default'), routing_key='default', queue_arguments={'x-max-priority':n 5}),\n Queue('garden', Exchange('garden'), routing_key='garden.#', queue_arguments={'x-max-priority':n 10}),\n Queue('keeper', Exchange('keeper'), routing_key='keeper.#', queue_arguments={'x-max-priority':n 10}),\n)\n\nCELERY_TASK_ROUTES = {\n 'garden.tasks.fetch_mls_image' : {'queue':n 'garden'},\n 'garden.tasks.save_image' : {'queue': 'garden'},\n 'garden.tasks.do_callback'n : {'queue': 'garden'},\n 'garden.tasks.clear_cloudflare_cache' : {'queue': 'garden'},\nn \ 'tourist.tasks.get_fetcher' : {'queue': 'tourist'},\n 'tourist.tasks.get_tour_urls'n : {'queue': 'tourist'},\n 'tourist.tasks.download_tour_images' : {'queue': 'tourist'},\nn \ 'tourist.tasks.smallest_image_size' : {'queue': 'tourist'},\n 'tourist.tasks.hash_and_compare'n : {'queue': 'tourist'},\n 'tourist.tasks.process_tours' : {'queue': 'tourist'},\nn \ 'tourist.tasks.all_done' : {'queue': 'tourist'},\n 'tourist.tasks.save_hd_images'n : {'queue': 'tourist'},\n 'keeper.tasks.create_sizes' : {'queue': 'keeper'},\nn \ 'celery_tasks.debug_task': {'queue': 'default'},\n}\n\n# Application definition\n\nINSTALLED_APPSn = [\n # Project\n 'celery',\n 'garden', # deals with retrieval of images\nn \ 'keeper', # deals with resizing and image processing tasks\n 'tourist', #n deals with virtual tours\n # Vendor Packages\n 'djangocms_admin_style',\nn \ # Django\n 'django.contrib.admin',\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\nn \ 'django.contrib.sessions',\n 'django.contrib.messages',\n 'django.contrib.staticfiles',\n]\n\nMIDDLEWAREn = [\n 'django.middleware.security.SecurityMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\nn \ 'django.middleware.common.CommonMiddleware',\n 'django.middleware.csrf.CsrfViewMiddleware',\nn \ 'django.contrib.auth.middleware.AuthenticationMiddleware',\n 'django.contrib.messages.middleware.MessageMiddleware',\nn \ 'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nROOT_URLCONFn = 'imagegateway.urls'\n\nTEMPLATES = [\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\nn \ 'DIRS': ['templates'],\n 'APP_DIRS': True,\n 'OPTIONS': {\nn \ 'context_processors': [\n 'django.template.context_processors.debug',\nn \ 'django.template.context_processors.request',\n 'django.contrib.auth.context_processors.auth',\nn \ 'django.contrib.messages.context_processors.messages',\n ],\nn \ },\n },\n]\n\nWSGI_APPLICATION = 'imagegateway.wsgi.application'\n\n\n#n Database\n\nDATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.postgresql',\nn \ 'NAME': 'imagegateway',\n 'USER': 'postgres',\n 'PASSWORD':n 'PostGresQL123',\n 'HOST': 'postgresql-imagegateway-dev-shared-headless',\nn \ 'PORT': 5432,\n }\n}\n\n\n# Password validation\n\nAUTH_PASSWORD_VALIDATORSn = [\n {\n 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',\nn \ },\n {\n 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',\nn \ },\n {\n 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',\nn \ },\n {\n 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',\nn \ },\n]\n\n\n# Internationalization\n\nLANGUAGE_CODE = 'en-us'\n\nTIME_ZONE =n 'UTC'\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static filesn (CSS, JavaScript, Images)\n\nSTATIC_URL = '/static/'\nSTATIC_ROOT = os.path.join(BASE_DIR,n 'static/')\n\n\n# Media files (Images)\n\nMEDIA_URL = '/media/'\n\n# Controls whethern Keras and backend is imported every server restart to improve restart times\n# Onlyn set the first bool!!! Then in production when DEBUG is set to false it will defaultn to True.\n# Example: \n# WITH_IMAGE_CLASSIFIER = True if DEBUG else True \n#n or WITH_IMAGE_CLASSIFIER = False if DEBUG else True\nWITH_IMAGE_CLASSIFIER = Truen if DEBUG else True\n\n# 20MB\nFILE_UPLOAD_MAX_MEMORY_SIZE = 20971520\nDATA_UPLOAD_MAX_MEMORY_SIZEn = 20971520\n\n# Cloudflare\nCLOUDFLARE_API_URL = 'https://api.cloudflare.com/client/v4/'\nCLOUDFLARE_API_KEYn = ''\nCLOUDFLARE_API_EMAIL = ''\nCLOUDFLARE_ZONE_ID = ''\n"n": parse error in "mynamespace-nonprod-chart/templates/configmap.yaml": template: mynamespace-nonprod-chart/templates/configmap.yaml:12: unexpected unclosed action in command
如果我设置了env.RABBITMQ_HOST:rabbitmq.mydomain.com
,我希望替换的值是:
CELERY_BROKER_URL = "amqp://admin:admin@rabbitmq.mydomain.com:5672/"
值:
useCustomApplicatonConfigs:
- mountPath: /var/www/html/django
type: py
name:
- settings
env:
CELERY_BROKER_URL: "amqp://admin:xWQ7ye7YotNif@rabbitmq-imagegateway-dev-shared-headless:5672"
有人知道正确的语法吗?我需要逃离@
还是什么?
编辑:添加值部分。
为了使配置正常工作,我必须更改两件事。
第一个问题是,我使用的是yaml注释,而不是运行helm install
时试图被替换的模板注释,所以我完全删除了它。根据helm文档,我应该使用{{-/*这是一个注释。*/-}}而不是#。
第二个问题是大括号{{
和}}
之间的空格。
之前:
CELERY_BROKER_URL = "amqp://{{ .Values.env.RABBITMQ_USER }}:{{ .Values.env.RABBITMQ_PASSWORD }}@{{ .Values.env.RABBITMQ_HOST }}:{{ .Values.env.RABBITMQ_PORT }}/"
工作后:
CELERY_BROKER_URL = "amqp://{{.Values.env.RABBITMQ_USER}}:{{.Values.env.RABBITMQ_PASSWORD}}@{{.Values.env.RABBITMQ_HOST}}:{{.Values.env.RABBITMQ_PORT}}/"