-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1157 from BenTheElder/storage
ship a better storage solution
- Loading branch information
Showing
6 changed files
with
247 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package node | ||
|
||
// these are well known paths within the node image | ||
const ( | ||
// TODO: refactor kubernetesVersionLocation to a common internal package | ||
kubernetesVersionLocation = "/kind/version" | ||
defaultCNIManifestLocation = "/kind/manifests/default-cni.yaml" | ||
defaultStorageManifestLocation = "/kind/manifests/default-storage.yaml" | ||
) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package node | ||
|
||
/* | ||
The default PV driver manifest and images are provisionally rancher.io/local-path-provisioner | ||
NOTE: we have customized it in the following ways: | ||
- storage is under /var instead of /opt | ||
- debian-base is used as the helper image (k8s already ships this upstream as the base for many images) instead of busybox | ||
- schedule to "master" kubeadm nodes (control-plane host) | ||
- install as the default storage class | ||
*/ | ||
|
||
var defaultStorageImages = []string{"rancher/local-path-provisioner:v0.0.11", "k8s.gcr.io/debian-base:v2.0.0"} | ||
|
||
const defaultStorageManifest = ` | ||
# kind customized https://github.com/rancher/local-path-provisioner manifest | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: local-path-storage | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: local-path-provisioner-service-account | ||
namespace: local-path-storage | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: local-path-provisioner-role | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["nodes", "persistentvolumeclaims"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: [""] | ||
resources: ["endpoints", "persistentvolumes", "pods"] | ||
verbs: ["*"] | ||
- apiGroups: [""] | ||
resources: ["events"] | ||
verbs: ["create", "patch"] | ||
- apiGroups: ["storage.k8s.io"] | ||
resources: ["storageclasses"] | ||
verbs: ["get", "list", "watch"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: local-path-provisioner-bind | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: local-path-provisioner-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: local-path-provisioner-service-account | ||
namespace: local-path-storage | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: local-path-provisioner | ||
namespace: local-path-storage | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: local-path-provisioner | ||
template: | ||
metadata: | ||
labels: | ||
app: local-path-provisioner | ||
spec: | ||
nodeSelector: | ||
node-role.kubernetes.io/master: '' | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Equal | ||
effect: NoSchedule | ||
serviceAccountName: local-path-provisioner-service-account | ||
containers: | ||
- name: local-path-provisioner | ||
image: rancher/local-path-provisioner:v0.0.11 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- local-path-provisioner | ||
- --debug | ||
- start | ||
- --helper-image | ||
- k8s.gcr.io/debian-base:v2.0.0 | ||
- --config | ||
- /etc/config/config.json | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /etc/config/ | ||
env: | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: local-path-config | ||
--- | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
namespace: kube-system | ||
name: standard | ||
annotations: | ||
storageclass.kubernetes.io/is-default-class: "true" | ||
provisioner: rancher.io/local-path | ||
volumeBindingMode: WaitForFirstConsumer | ||
reclaimPolicy: Delete | ||
--- | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: local-path-config | ||
namespace: local-path-storage | ||
data: | ||
config.json: |- | ||
{ | ||
"nodePathMap":[ | ||
{ | ||
"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", | ||
"paths":["/var/local-path-provisioner"] | ||
} | ||
] | ||
} | ||
` | ||
|
||
// legacy default storage class for older than Kubernetes v1.12.0 | ||
// we need this for e2es (StatefulSet) | ||
// newer kind images ship a storage driver manifest | ||
const legacyDefaultStorage = `# host-path based default storage class | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
namespace: kube-system | ||
name: standard | ||
annotations: | ||
storageclass.kubernetes.io/is-default-class: "true" | ||
provisioner: kubernetes.io/host-path` |
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