Skip to content

Commit f69ea5c

Browse files
authored
Merge pull request #8369 from johngmyers/automated-cherry-pick-of-#6465-#8368-upstream-release-1.17
Automated cherry pick of #6465: Allow local filesystem state stores #8368: Add a warning when using file:// state store
2 parents b19d58b + 3b9464b commit f69ea5c

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

cmd/kops/util/factory.go

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ func (f *Factory) Clientset() (simple.Clientset, error) {
118118

119119
f.clientset = vfsclientset.NewVFSClientset(basePath, allowVFSList)
120120
}
121+
if strings.HasPrefix(registryPath, "file://") {
122+
klog.Warning("The local filesystem state store is not functional for running clusters")
123+
}
121124
}
122125

123126
return f.clientset, nil

docs/state.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ though we have to copy the data from the state store to a file where components
99

1010
The state store uses kops's VFS implementation, so can in theory be stored anywhere.
1111
As of now the following state stores are supported:
12-
13-
* Amazon AWS S3 (s3://)
14-
* local filesystem (file://)
15-
* Digital Ocean (do://)
12+
* Amazon AWS S3 (`s3://`)
13+
* local filesystem (`file://`) (only for dry-run purposes, see [note](#local-filesystem-state-stores) below)
14+
* Digital Ocean (`do://`)
1615
* MemFS (memfs://)
17-
* Google Cloud (gs://)
18-
* Kubernetes (k8s://)
19-
* OpenStack Swift (swift://)
20-
* AliCloud (oss://)
16+
* Google Cloud (`gs://`)
17+
* Kubernetes (`k8s://`)
18+
* OpenStack Swift (`swift://`)
19+
* AliCloud (`oss://`)
2120

2221
The state store is just files; you can copy the files down and put them into git (or your preferred version control system).
2322

@@ -47,6 +46,16 @@ There are a few ways to configure your state store. In priority order:
4746
+ config file `$HOME/.kops.yaml`
4847
+ config file `$HOME/.kops/config`
4948

49+
## Local filesystem state stores
50+
51+
The local filesystem state store (`file://`) is **not** functional for running clusters. It is permitted so as to enable review workflows.
52+
53+
For example, in a review workflow, it can be desirable to check a set of untrusted changes before they are applied to real infrastructure. If submitted untrusted changes to configuration files are naively run by `kops replace`, then Kops would overwrite the state store used by production infrastructure with changes which have not yet been approved. This is dangerous.
54+
55+
Instead, a review workflow may download the contents of the state bucket to a local directory (using `aws s3 sync` or similar), set the state store to the local directory (e.g. `--state file:///path/to/state/store`), and then run `kops replace` and `kops update` (but for a dry-run only - _not_ `kops update --yes`). This allows the review process to make changes to a local copy of the state bucket, and check those changes, without touching the production state bucket or production infrastructure.
56+
57+
Trying to use a local filesystem state store for real (i.e. `kops update --yes`) clusters will not work since the Kubernetes nodes in the cluster need to be able to read from the same state bucket, and the local filesystem will not be mounted to all of the Kubernetes nodes. In theory, a cluster administrator could put the state store on a shared NFS volume that is mounted to the same directory on each of the nodes; however, that use case is not supported as of yet.
58+
5059
### Configuration file example:
5160

5261
`$HOME/.kops/config` might look like this:
@@ -171,4 +180,4 @@ if err != nil {
171180

172181
gcsClient, err := storage.New(httpClient)
173182

174-
```
183+
```

util/pkg/vfs/vfs.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func IsClusterReadable(p Path) bool {
102102
}
103103

104104
switch p.(type) {
105-
case *S3Path, *GSPath, *SwiftPath, *OSSPath:
105+
case *S3Path, *GSPath, *SwiftPath, *OSSPath, *FSPath:
106106
return true
107107

108108
case *KubernetesPath:
@@ -111,9 +111,6 @@ func IsClusterReadable(p Path) bool {
111111
case *SSHPath:
112112
return false
113113

114-
case *FSPath:
115-
return false
116-
117114
case *MemFSPath:
118115
return false
119116

0 commit comments

Comments
 (0)