Last active
October 18, 2023 05:24
-
-
Save gmaslowski/117f3535173d733e007d0c6c83564888 to your computer and use it in GitHub Desktop.
k8s-cassandra-nodeLabel2pod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: cassandra-rackdc | |
data: | |
cassandra-rackdc.properties: | | |
dc= datacenter | |
rack= RACK | |
--- | |
apiVersion: apps/v1beta1 | |
kind: Deployment | |
metadata: | |
name: node2pod | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
name: node2pod | |
app: node2pod | |
spec: | |
initContainers: | |
- name: node2pod | |
imagePullPolicy: IfNotPresent | |
image: <image-with-k8s-access> | |
command: | |
- "sh" | |
- "-c" | |
- "cp /config/cassandra-rackdc.properties /shared/cassandra-rackdc.properties && \ | |
sed -i.bak s/RACK/$(kubectl get no -Llabel | grep ${NODE_NAME} | awk '{print $6}')/g /shared/cassandra-rackdc.properties" | |
env: | |
- name: NODE_NAME | |
valueFrom: | |
fieldRef: | |
fieldPath: spec.nodeName | |
volumeMounts: | |
- name: cassandra-rackdc | |
mountPath: /config/ | |
- name: shared | |
mountPath: /shared/ | |
containers: | |
- name: cassandra | |
image: cassandra | |
volumeMounts: | |
- name: shared | |
mountPath: /etc/cassandra-rackdc.properties | |
subPath: cassandra-rackdc.properties | |
volumes: | |
- name: cassandra-rackdc | |
configMap: | |
name: cassandra-rackdc | |
- name: shared | |
emptyDir: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment