Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems running Kubernetes in Docker for Windows #4333

Closed
jseldess opened this issue Feb 7, 2019 · 4 comments
Closed

Problems running Kubernetes in Docker for Windows #4333

jseldess opened this issue Feb 7, 2019 · 4 comments
Assignees
Labels
C-doc-improvement no-issue-activity O-external Origin: Issue comes from external users. P-2 Normal priority; secondary task T-something-broken X-stale
Milestone

Comments

@jseldess
Copy link
Contributor

jseldess commented Feb 7, 2019

Jesse Seldess (jseldess) commented:

Moved from #3184.

From @jazoom:

I have been using a CockroachDB cluster in Swarm Mode in Docker for Windows for a few months now and it has worked well (was using volumes). I'd never tried direct path mapping to Windows file system. What's actually the difference that makes one work and not the other? It seems docker volumes are pretty much the same thing except docker keeps the data in a special directory on the host that you don't need to know the path of.

Now I'm moving everything over to Kubernetes in Docker for Windows and it seems hostPath isn't working for CockroachDB. I haven't found an equivalent of the docker volumes here that work around this issue. What can we do in Kubernetes?

...

Circling back to answer my own question in case it helps someone else in future.

This is how I got around this issue in Kubernetes in Docker for Windows.

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: cockroachdb
spec:
  replicas: 1
  template:
    spec:
      volumes:
      - name: data
        $patch: delete
      - name: data
        emptyDir: {}
      - name: dump
        hostPath:
          path: /E/kubernetes-volumes/cockroachdb-dump
          type: DirectoryOrCreate
      initContainers:
      - name: restore-data
        image: busybox:1.29.2
        command: ['sh', '-c', 'if [ -e /cockroach/dump/data/ ]; then echo "restoring data..." && cp -rf /cockroach/dump/data/. /cockroach/cockroach-data/ && echo "data restored"; fi']
        volumeMounts:
        - name: data
          mountPath: /cockroach/cockroach-data
        - name: dump
          mountPath: /cockroach/dump
      containers:
      - name: cockroachdb
        volumeMounts:
        - name: dump
          mountPath: /cockroach/dump
        command:
        - "/bin/bash"
        - "-ecx"
        - "exec /cockroach/cockroach start --insecure --logtostderr --cache 25% --max-sql-memory 25% --http-host 0.0.0.0"
        lifecycle:
          preStop:
            exec:
              command:  ['sh', '-c', 'echo "dumping data..." && cp -r /cockroach/cockroach-data/ /cockroach/dump/data-temp/ && rm -rf /cockroach/dump/data/ && mv /cockroach/dump/data-temp/ /cockroach/dump/data/ && echo "data dumped"']

The above is actually the file I use to patch the production cockroachdb.yaml with Kustomize (which is where $patch: delete comes from, which isn't valid Kubernetes config YAML). It essentially shows the changes that need to be made to a normal cockroachdb config.

It's a little hacky, but it seems to work well. After the container has received the signal to terminate it saves CockroachDB's data to a hostPath. Before the pod starts next time an initContainer runs and restores that data to CockroachDB's data directory. I used an initContainer instead of a postStart hook because postStart runs in parallel to the container's entry command.

This gets around the issue because CockroachDB doesn't ever have to do its operations on a hostPath, yet the data is still persisted to a hostPath between pod restarts.

Jira Issue: DOC-235

@jseldess
Copy link
Contributor Author

jseldess commented Feb 7, 2019

Follow-up from @dlouwers:

Is there a proposed workaround like a certain modification to the cockroachdb-statefulset-secure.yaml file to make this work on WIndows?

Follow-up from @xambas84:

sorry for the bump. but are there any plans to fix this?

@jseldess jseldess added O-external Origin: Issue comes from external users. T-something-broken A-ops&tools P-1 High priority; must be done this release labels Feb 7, 2019
@jseldess jseldess added this to the 2.2 milestone Feb 7, 2019
@jseldess jseldess modified the milestones: 2.2, 19.1 Feb 25, 2019
@jseldess jseldess self-assigned this Apr 2, 2019
@jseldess
Copy link
Contributor Author

jseldess commented Apr 3, 2019

Adding @rolandcrosby for PM support.

@jseldess jseldess modified the milestones: 19.1, 19.2 Apr 18, 2019
@jseldess jseldess modified the milestones: 19.2, 20.1 Sep 24, 2019
@jseldess jseldess assigned taroface and unassigned jseldess Oct 31, 2019
@jseldess jseldess added P-2 Normal priority; secondary task and removed P-1 High priority; must be done this release labels Oct 31, 2019
@jseldess jseldess modified the milestones: 20.1, Later Oct 31, 2019
@jseldess
Copy link
Contributor Author

Moving this to later in favor of other Kubernetes-centric docs projects for 20.1. We can reassess/reprioritize as needed.

@jseldess jseldess added this to Not planned (Later) in Kubernetes docs work Oct 31, 2019
@jseldess jseldess added A-ops and removed A-channel labels Nov 26, 2019
@rolandcrosby rolandcrosby removed their assignment Jan 16, 2020
@github-actions
Copy link

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB docs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-doc-improvement no-issue-activity O-external Origin: Issue comes from external users. P-2 Normal priority; secondary task T-something-broken X-stale
Projects
No open projects
Kubernetes docs work
  
Not planned (Later)
Development

No branches or pull requests

3 participants