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
82638f8b
Commit
82638f8b
authored
Aug 19, 2015
by
Muhammed Uluyol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add conversion function from GCE storage units to kubernetes units.
parent
14b554ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
configure-vm.sh
cluster/gce/configure-vm.sh
+15
-1
No files found.
cluster/gce/configure-vm.sh
View file @
82638f8b
...
...
@@ -308,12 +308,26 @@ EOF
if
[[
"
${
ENABLE_CLUSTER_REGISTRY
}
"
==
true
&&
-n
"
${
CLUSTER_REGISTRY_DISK
}
"
]]
;
then
cat
<<
EOF
>>/srv/salt-overlay/pillar/cluster-params.sls
cluster_registry_disk_type: gce
cluster_registry_disk_size:
$
{
CLUSTER_REGISTRY_DISK_SIZE
//GB/Gi
}
cluster_registry_disk_size:
$
(
convert-bytes-gce-kube
${
CLUSTER_REGISTRY_DISK_SIZE
})
cluster_registry_disk_name:
${
CLUSTER_REGISTRY_DISK
}
EOF
fi
}
# The job of this function is simple, but the basic regular expression syntax makes
# this difficult to read. What we want to do is convert from [0-9]+B, KB, KiB, MB, etc
# into [0-9]+, Ki, Mi, Gi, etc.
# This is done in two steps:
# 1. Convert from [0-9]+X?i?B into [0-9]X? (X denotes the prefix, ? means the field
# is optional.
# 2. Attach an 'i' to the end of the string if we find a letter.
# The two step process is needed to handle the edge case in which we want to convert
# a raw byte count, as the result should be a simple number (e.g. 5B -> 5).
function
convert-bytes-gce-kube
()
{
local
-r
storage_space
=
$1
echo
"
${
storage_space
}
"
|
sed
-e
's/^\([0-9]\+\)\([A-Z]\)\?i\?B$/\1\2/g'
-e
's/\([A-Z]\)$/\1i/'
}
# This should only happen on cluster initialization.
#
# - Uses KUBE_PASSWORD and KUBE_USER to generate basic_auth.csv.
...
...
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