У меня есть проект Maven, который использует build.properties, который при сборке превращается в projectname.properties в папке WEB-INF.
Этот файл содержит учетные данные подключения к БД, поэтому я хотел использовать configMapэто так, что мне не нужно фиксировать пароли БД в git.
Кажется, мне не нравится, когда я монтирую configMap как файл в развертывании.
Мой deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: pyx-tr-staging
labels:
app: pyx-tr-staging
namespace: pyx-tr
spec:
replicas: 1
selector:
matchLabels:
app: pyx-tr-staging
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 33%
template:
metadata:
labels:
app: pyx-tr-staging
spec:
containers:
- name: pyx-tr-staging
image: registry.gitlab.com/lb-dev/projects/pyx/pyx-tr:<VERSION>
ports:
- containerPort: 8080
volumeMounts:
- name: config-volume
mountPath: /propfiles/
lifecycle:
postStart:
exec:
command: ["cp", "/propfiles/pyx.properties", "/usr/local/tomcat/webapps/ROOT/WEB-INF/"]
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 2
periodSeconds: 2
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 2
periodSeconds: 2
imagePullSecrets:
- name: regcred
volumes:
- name: config-volume
configMap:
name: pyx-tr-config
My Configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: pyx-tr-config
namespace: pyx-tr
data:
pyx.properties: |
pyx.cookie_domain=.localhost
pyx.max_users=100
pyx.max_games=25
pyx.include_inactive_cardsets=false
pyx.broadcast_connects_and_disconnects=true
pyx.global_chat_enabled=true
pyx.game_chat_enabled=true
# allow fill-in-the-blank cards at all. Limits are set via constants in GameOptions.
pyx.allow_blank_cards=true
# allow identification codes to be used without HTTPS
pyx.insecure_id_allowed=true
# set this to some secure random value, and never change it, unless you want to break all codes
pyx.id_code_salt=
# comma-separated listed of IP addresses (v4 or v6) from which users are considered admins.
# IPv6 addresses must be fully spelt out without omitting groups of 0s with ::
pyx.admin_addrs=127.0.0.1,0:0:0:0:0:0:0:1
# comma-separated list of strings banned from appearing in nicks.
pyx.banned_nicks=xyzzy
# The name of a class that implements net.socialgamer.cah.util.ChatFilter.ShadowBannedStringProvider
# which will then be called to get the shadowbanned strings.
# Ideally we'd just have the list of strings here, but providing unicode characters directly gets
# mangled during the build process, and for some reason unicode escapes were not being loaded
# properly at runtime.
# If this is blank, it is ignored and no strings will cause such filtering to occur.
pyx.shadowban_strings_provider=
# Settings for global chat protection. Some of these do not apply to game chats.
# Ratio of 'basic' characters to length of message. Basic characters are defined by
# Character.isJavaIdentifierPart, which stipulates:
# -it is a letter
# -it is a currency symbol (such as '$')
# -it is a connecting punctuation character (such as '_')
# -it is a digit
# -it is a numeric letter (such as a Roman numeral character)
# -it is a combining mark
# -it is a non-spacing mark
# -isIdentifierIgnorable(codePoint) returns true for the character
pyx.global.basic_ratio=.5
# A message must have at least this many characters for that ratio to apply.
pyx.global.basic_min_len=10
# Message longer than min_len characters cannot have more than ratio of CAPS CHARACTERS
pyx.global.capslock_min_len=50
pyx.global.capslock_ratio=.5
# messages longer than min_len characters require at least min_count spaces between words
pyx.global.spaces_min_len=50
pyx.global.spaces_min_count=4
# this many messages to global chat in that many seconds is considered chatting too fast.
pyx.global.flood_count=3
# seconds
pyx.global.flood_time=25
# Messages with more than repeated_words_min_count words must have at least
# repeated_words_unique_ratio unique words in them.
pyx.global.repeated_words_min_count=10
pyx.global.repeated_words_unique_ratio=.5
# Settings for game chat protection. If it isn't listed here, it isn't supported.
# same but for game chats
pyx.game.flood_count=5
# seconds
pyx.game.flood_time=30
# for production use, use postgres
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.driver_class=org.postgresql.Driver
hibernate.url=jdbc:postgresql://postgres/db
# for local use, you can also use sqlite
# hibernate.dialect=net.socialgamer.cah.hibernate.SqliteDialect
# hibernate.driver_class=org.sqlite.JDBC
# hibernate.url=jdbc:sqlite:pyx.sqlite
# these likely need specified even with sqlite, even though they don't matter
hibernate.username=pyx
hibernate.password=REDACTED
# debugging information
hibernate.sql.show=false
hibernate.sql.format=false
Когда я внедряю это в мой кластер Kubernetes, контейнер никогда не запускается, так как он не проходит проверку жизнеспособности и готовности, поэтому он продолжает перезапускать контейнер.
Если я просто сохраню файл примера, он будет работать нормально
Я получаю ошибку, что postStart жизненного цикла возвращает это
Exec lifecycle hook ([cp /propfiles/pyx.properties /usr/local/tomcat/webapps/ROOT/WEB-INF/]) for Container "pyx-tr-staging" in Pod "pyx-tr-staging-67b47c75cc-nlvzg_pyx-tr(724820f1-9980-11e9-b0bb-aa44c6500e0e)" failed - error: command 'cp /propfiles/pyx.properties /usr/local/tomcat/webapps/ROOT/WEB-INF/' exited with 1: cp: cannot create regular file '/usr/local/tomcat/webapps/ROOT/WEB-INF/': No such file or directory , message: "cp: cannot create regular file '/usr/local/tomcat/webapps/ROOT/WEB-INF/': No such file or directory\n"