Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
df34e000
Commit
df34e000
authored
May 14, 2018
by
Mike Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NFS support for default storage
parent
bd0d0937
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
0 deletions
+105
-0
layer.yaml
cluster/juju/layers/kubernetes-worker/layer.yaml
+1
-0
metadata.yaml
cluster/juju/layers/kubernetes-worker/metadata.yaml
+3
-0
kubernetes_worker.py
...ju/layers/kubernetes-worker/reactive/kubernetes_worker.py
+62
-0
nfs-provisioner.yaml
...u/layers/kubernetes-worker/templates/nfs-provisioner.yaml
+39
-0
No files found.
cluster/juju/layers/kubernetes-worker/layer.yaml
View file @
df34e000
...
@@ -14,6 +14,7 @@ includes:
...
@@ -14,6 +14,7 @@ includes:
-
'
interface:kube-control'
-
'
interface:kube-control'
-
'
interface:aws'
-
'
interface:aws'
-
'
interface:gcp'
-
'
interface:gcp'
-
'
interface:mount'
config
:
config
:
deletes
:
deletes
:
-
install_from_upstream
-
install_from_upstream
...
...
cluster/juju/layers/kubernetes-worker/metadata.yaml
View file @
df34e000
...
@@ -7,6 +7,7 @@ maintainers:
...
@@ -7,6 +7,7 @@ maintainers:
-
Konstantinos Tsakalozos <kos.tsakalozos@canonical.com>
-
Konstantinos Tsakalozos <kos.tsakalozos@canonical.com>
-
Charles Butler <Chuck@dasroot.net>
-
Charles Butler <Chuck@dasroot.net>
-
Matthew Bruzek <mbruzek@ubuntu.com>
-
Matthew Bruzek <mbruzek@ubuntu.com>
-
Mike Wilson <mike.wilson@canonical.com>
description
:
|
description
:
|
Kubernetes is an open-source platform for deploying, scaling, and operations
Kubernetes is an open-source platform for deploying, scaling, and operations
of application containers across a cluster of hosts. Kubernetes is portable
of application containers across a cluster of hosts. Kubernetes is portable
...
@@ -32,6 +33,8 @@ requires:
...
@@ -32,6 +33,8 @@ requires:
interface
:
aws
interface
:
aws
gcp
:
gcp
:
interface
:
gcp
interface
:
gcp
nfs
:
interface
:
mount
provides
:
provides
:
cni
:
cni
:
interface
:
kubernetes-cni
interface
:
kubernetes-cni
...
...
cluster/juju/layers/kubernetes-worker/reactive/kubernetes_worker.py
View file @
df34e000
...
@@ -1174,3 +1174,65 @@ def _write_gcp_snap_config(component):
...
@@ -1174,3 +1174,65 @@ def _write_gcp_snap_config(component):
daemon_env
+=
'{}={}
\n
'
.
format
(
gcp_creds_env_key
,
creds_path
)
daemon_env
+=
'{}={}
\n
'
.
format
(
gcp_creds_env_key
,
creds_path
)
daemon_env_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
daemon_env_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
daemon_env_path
.
write_text
(
daemon_env
)
daemon_env_path
.
write_text
(
daemon_env
)
def
get_first_mount
(
mount_relation
):
mount_relation_list
=
mount_relation
.
mounts
()
if
mount_relation_list
and
len
(
mount_relation_list
)
>
0
:
# mount relation list is a list of the mount layer relations
# for now we just use the first one that is nfs
for
mount
in
mount_relation_list
:
# for now we just check the first mount and use that.
# the nfs charm only supports one for now.
if
(
'mounts'
in
mount
and
mount
[
'mounts'
][
0
][
'fstype'
]
==
'nfs'
):
return
mount
[
'mounts'
][
0
]
return
None
@when
(
'nfs.available'
)
def
nfs_state_control
(
mount
):
''' Determine if we should remove the state that controls the re-render
and execution of the nfs-relation-changed event because there
are changes in the relationship data, and we should re-render any
configs '''
mount_data
=
get_first_mount
(
mount
)
if
mount_data
:
nfs_relation_data
=
{
'options'
:
mount_data
[
'options'
],
'host'
:
mount_data
[
'hostname'
],
'mountpoint'
:
mount_data
[
'mountpoint'
],
'fstype'
:
mount_data
[
'fstype'
]
}
# Re-execute the rendering if the data has changed.
if
data_changed
(
'nfs-config'
,
nfs_relation_data
):
hookenv
.
log
(
'reconfiguring nfs'
)
remove_state
(
'nfs.configured'
)
@when
(
'nfs.available'
)
@when_not
(
'nfs.configured'
)
def
nfs_storage
(
mount
):
'''NFS on kubernetes requires nfs config rendered into a deployment of
the nfs client provisioner. That will handle the persistent volume claims
with no persistent volume to back them.'''
mount_data
=
get_first_mount
(
mount
)
if
not
mount_data
:
return
addon_path
=
'/root/cdk/addons/{}'
# Render the NFS deployment
manifest
=
addon_path
.
format
(
'nfs-provisioner.yaml'
)
render
(
'nfs-provisioner.yaml'
,
manifest
,
mount_data
)
hookenv
.
log
(
'Creating the nfs provisioner.'
)
try
:
kubectl
(
'apply'
,
'-f'
,
manifest
)
except
CalledProcessError
as
e
:
hookenv
.
log
(
e
)
hookenv
.
log
(
'Failed to create nfs provisioner. Will attempt again next update.'
)
# noqa
return
set_state
(
'nfs.configured'
)
cluster/juju/layers/kubernetes-worker/templates/nfs-provisioner.yaml
0 → 100644
View file @
df34e000
apiVersion
:
storage.k8s.io/v1
kind
:
StorageClass
metadata
:
name
:
default
annotations
:
storageclass.kubernetes.io/is-default-class
:
"
true"
provisioner
:
fuseim.pri/ifs
---
kind
:
Deployment
apiVersion
:
extensions/v1beta1
metadata
:
name
:
nfs-client-provisioner
spec
:
replicas
:
1
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
app
:
nfs-client-provisioner
spec
:
containers
:
-
name
:
nfs-client-provisioner
image
:
quay.io/external_storage/nfs-client-provisioner:latest
volumeMounts
:
-
name
:
nfs-client-root
mountPath
:
/persistentvolumes
env
:
-
name
:
PROVISIONER_NAME
value
:
fuseim.pri/ifs
-
name
:
NFS_SERVER
value
:
{{
hostname
}}
-
name
:
NFS_PATH
value
:
{{
mountpoint
}}
volumes
:
-
name
:
nfs-client-root
nfs
:
server
:
{{
hostname
}}
path
:
{{
mountpoint
}}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment