k8s-cassandra-nodeLabel2pod
--- | |
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