►
From YouTube: Managing Multiple KubeConfig - Simon Bein, Kubermatic
Description
Maybe you have run into this situation: You have started extensively using Kubernetes and now manage multiple clusters. But every time you want to switch to another cluster, you manually need to change the file or context.
Website: https://www.kubermatic.com/
Organized by @Microsoft @kubermatic7173 @SysEleven
Thanks to our sponsors @CapgeminiGlobal, @gardenio, @sysdig, @SUSE, @anynines, @redhat, nginx, serve-u
A
A
A
With
that
I
want
you
guys
to
remember
that
this
is
an
opinionated
talk,
while
I
will
present
five
Solutions
as
objectively
as
I
can,
of
course,
I
have
an
opinion
in
this.
I
also
have
a
personal
stake
in
this,
which
we'll
find
out
later
more
about,
but
overall,
it's
important
I
think
if
there's
any
takeaway
from
today's
talk
for
you
guys,
it's
that
you
need
to
find
what
works
for
you
right.
You
need
to
find
a
solution
that
fits
best.
A
Your
situation
and
everyone
here
in
this
room
is
in
a
different
situation
in
their
native's
Journey,
but
also
in
general,
how
they
would
like
to
organize
things
with
that.
Another
part
is
Life's,
too
short
to
always
type
Cube
CTL.
So
if
you,
in
any
case
in
this
talk,
see
a
KC,
that
is
just
what
I
have
Alias
Cube
CTL
too,
and
that's
what
I'm
going
to
go
with.
A
So
whenever
you
see
Casey,
it
is
short
for
cube
CTL
in
this
talk
with
that,
we
can
hop
into
some
basics
for
cubeconfig,
usually
hoop
CTL
manages
access
to
its
clusters
and
also
the
whole
manage
watch
user
access
which
cluster
in
one
single
file.
It's
the
you
config
by
default,
it's
in
your
dot,
Cube
directory
under
at
the
file
at
the
file
name
called
config.
A
However,
this
file
can
store
multiple
clusters
or
multiple
users,
and
it's
using
like
a
helper
construct
called
a
context.
So
context
essentially
is
a
mapping
of
a
user
and
a
cluster,
and
by
that
you
can
basically
have
all
your
clusters
and
all
of
your
users
in
a
singular
file,
and
you
can,
by
default,
switch
that
using
cubicity
error,
config
use
context.
A
One
thing
that's
interesting,
though,
is
that
the
file
is
structured
in
a
very
specific
way,
and
that
does
not
allow
you
to
just
append
new
cubeconfigs.
So
if
you
just
had
two
files,
you
cannot
just
concatenate
them
together
and
we're
going
to
have
a
quick
look.
Why
that
is
here.
We
can
see
a
sample,
a
structure
of
it
and
you
can
see
it's
divided
into
three
major
top
level.
Keys
clusters
contexts,
users,
and
you
can
also
see
it
is
a
yaml
file
by
default
like
even
though
it
doesn't
have
the
file
extension.
A
A
In
addition,
also,
the
current
context
of
that
file
that
is
currently
used
is
also
stored
in
a
field
called
current
context,
and
by
now
you
can
guys
can
already
kind
of
see
that
we
need
some
sort
of
tooling
to
merge
these
into,
and
the
good
news
is
actually
for
all
the
purists
out
there.
You
can
actually
do
it
with
Cube
CTL
and
how
that
works.
I'm
going
to
show
you
so
the
first
thing
is
that
the
cubeconfig
you
use
the
DS.
The
default
is
dot
Cube
config.
A
You
can
go
here
in
the
front
if
you
guys
want
to
so
what
maybe
some
of
you
or
what's
new-
and
it
was
new
to
me-
is
there
is
actually
a
little
hack
that
you
can
use
to
merge
multiple
cubeconfig
files
into
one
and
I
would
like
to
you
guys
to
pay
attention
now
to
the
cubeconfig
variable
at
the
start
of
this
command.
You
can
see
multiple
files
are
separated
with
a
colon,
and
if
you
do
that,
it
only
works
by
the
way
for
the
cube,
CTL
config
command
for
all
the
other
ones.
A
Similarly,
you
can
also
split
them
if
you
use
the
Minify
flag
in
combination
with
a
context
flag,
so
it
does
work
so
everyone,
just
if
you
want
to
stay
on
the
pure
side.
Maybe
you
can
Alias
also
these
commands,
but
obviously
these
come
with
some
downsides
right.
One
downside
is,
if
you
decide
to
merge
all
of
them
in
one
file,
you
will
get
one
gigantic
file
and
you
need
to
be
aware
of
what
you
have
named.
What
or
if
you
decide
to
split
all
of
them.
A
A
And
I
just
wanted
to
show
you
guys,
but
you
have
heard
of
it.
It
is
possible,
but
with
that
I
think,
let's
dive
into
some
more
advanced
Solutions
and
we
did
have
a
survey
internally
at
Cuba
Matic.
A
What
what
like
kind
of
our
developers
use
and
a
good
colleague
of
mine
voycheck,
he
said
well
I
just
have
three
lines
for
this
and
in
honor
of
him
the
next
solution
is
called
voice,
checks,
genius,
reliner
and
I'm,
going
to
show
you
first
what
it
does
and
then
we're
gonna
look
into
how
it
works.
So
a
little
prayer
to
the
demo
gods
and
we'll
get
on
with
our
first
little
demo,
so
just
to
show
the
setup
that
we
have
real,
quick,
so
I've
just
created
a
directory
called
cubeconfigs
in
that
directory.
A
There
are
three
sample
Cube
configs.
If
we
just
look
into
them
real,
quick.
So,
for
example,
if
you
look
into
the
Simon's
fun
cluster
cubeconfig,
you
can
see
it's
just
a
standard
config
and
it
just
contains
a
single
context.
So
if
I
go
in
here,
if
I
go
in
here,
you
guys
can
see.
There
is
only
one
context
and
it's
a
very
simple
free
files,
simple
configuration
for
this
now.
If
we
have
a
look
into
this,
so
I've
called
vertex
solution,
kcsw
for
qcq
config
switch.
A
If
we
hit
enter
what
we
can
see,
is
it
pops
up
a
little
dialog
that
shows
exactly
these
three
files
that
I
just
showed
you
and
that
does
support
some
little
fuzzy
search.
So
if
I,
for
example,
type
in
Simon
here
and
I
hit
enter
he's
gonna
set
this
so
for
the
purpose
of
this
demo
oops
my
Mouse
there's
my
mouse
and
for
the
purpose
of
this
demo,
I
built
in
a
little
prompt
that
shows
you
the
current
cluster.
Okay,
just
to
speed
this
up,
but
just
to
prove
it
to
you
guys.
A
If
we
would
Echo
cubeconfig,
we
can
see
it
points
exactly
to
the
file
that
we
just
selected
in
the
dialog
and
well
now.
How
does
this
work
with
Reliance
oops.
A
So
yeah
this
is
it
usually
I,
don't
like
showing
code
in
presentations,
but
I
think
the
lines
is
perfectly
fine.
Also
the
slides
will
be
available,
so
you
can
just
copy
these
later
on,
but
essentially
what
we
do
is
we
give
it
the
search
directory.
We
run
a
find,
only
search
for
file
types
and
then
we
pipe
it
into
fzf.
A
Fzf
was
the
one
that
showed
us
the
fuzzy
finding
and
that
little
pop-up
dialog,
but
you
could
pipe
this
into
any
type
of
command
line,
prompter
that
you
would
want
like
it's
up
to
you
and
then
it
just
sets
Cube
config
to
whatever
you
chose
so
I
found
this
pretty
neat,
if
you
say
I,
don't
really
like
splitting
all
my
Cube
conflicts
into
files,
which
is
a
requirement
for
this.
A
So
if
you
want
to
use
this
solution,
you
would
have
to
split
all
of
your
Cube
configs
into
multiple
files,
and
each
cubeconfig
can
only
contain
one
context
because
it
just
searches
for
the
files
and
sets
it
to
whatever
is
in
the
file.
And
if
you
say
I
don't
really
want
this
I
want
everything
in
One,
Singular
solution,
then
the
next.
The
next
solution
might
be
something
for
you.
It's
Cube
CTX,
since
it
has
like
13k
stars
on
GitHub
I'm,
assuming
it's
rather
familiar.
A
It
was
built
by
Ahmed
during
his
time
at
Google
and
I'm,
going
to
demo
to
it
first.
So
we'll
have
a
look
at
the
next
solution.
Real
quick
for
this
solution
for
this
solution.
I
have
created
all
in
one
Cube
config,
so
just
I've
merged
just
these
three
configs,
because
obviously,
if
we
only
want
to
use
one
config,
we
need
to
put
in
all
the
contexts
for
this.
So
if
we
now
run
Cube
CTX,
which
is
the
command
again,
it
also
integrates
with
fzf.
A
I
should
mention
that
this
also
comes
with
another
command.
That's
called
Cube
NS
to
switch
to
names,
spaces
just
to
be
clear
in
this
demo.
It
doesn't
work
because
it
goes
to
the
cluster
and
checks.
Actually
if
the
namespace
exists,
so
I
cannot
show
it
to
you
here,
because
I
didn't
want
to
run
three
clusters
for
this
demo
now,
just
to
be
clear,
it
can
also
do
that.
A
However
I-
and
this
is
now
where
this
talks
good,
really
opinion.
It
I
have
struggled
a
long
time
with
this
functionality,
and
the
reason
for
this
is
that
I
like
to
be
in
multiple
clusters.
A
At
the
same
time,
that
was
the
one
thing
that
I
would
really
like
to
do
and
if
we
go
just
into
here-
and
let's
say
you
can
see
now
here
in
the
bottom-
I've
I've
spun
up
a
new
shell
and,
let's
say
oops,
so
we
are
in
Simon's,
fun,
cluster,
sorry
and
now,
if
I
run
Cube
City
oops
qctx
here
and
if
I
switch
to
let's
say
uat
environment
and
what's
going
to
happen,
is
it
has
switched
down
there
perfect?
A
It
just
sets
the
current
context
field
to
whatever
was
selected
and
because
both
of
them
depend
on
the
same
file,
it
will
change
it
for
both
of
them,
and
that
was
something
that
also
is
true
for
namespaces,
so
you
could,
for
example,
in
these
two
shell
sessions.
You
could
not
be
in
different
namespaces,
at
least
with
the
board,
with
the
tools
that
are
on
board.
Oops.
Yes,
so
for
this
there
then,
is
another
tool
that
has
become
quite
popular:
it's
called
QB.
A
It's
also
you
can
see
1.2
K
stars
on
GitHub,
so
it's
also
rather
popular
and
I'm,
going
to
show
it
to
you
oops
how
it
works
now
so
solution
number
five
is
QB.
Qb
also
takes
in
a
directory
and
just
reads
in
all
the
files
I'm
not
going
to
show
that
one
that
part
again,
but
if
I
just
run
q
b
c
t
x,
it
again
integrates
with
szf
I.
Think
at
this
point.
If
it
comes
a
bit
of
a
meme,
almost
let's
say
we
switch
to
to
uat.
A
Maybe,
and
now
we
see
something
weird
has
happened
right.
Suddenly,
our
shell
prompt
looks
completely
different
right.
It's
just
now:
it's
not
the
nice
green
and
blue
anymore.
It's
just
suddenly
just
a
white
prompt
I
want
to
show
you
guys
what
happened
here.
So
if
we
opened
us
another
shell
and
if
we
just
run.
A
We
can
actually
see
what
has
happened
here
so,
even
though
it
looks
like
here,
we
are
in
a
brand
new
shell
and
QB
has
already
finished
it
hasn't,
because
what
QB
does
is
QB
lets
the
qbctx
command
running.
It
leaves
it
running,
and
that
command
then
spawns
a
new
bash
which
just
takes
in
all
the
settings
from
the
old
one
and
the
reason
why
it
does
that
is
so.
A
It
has
control
over
the
new
bash
because
it
wants
to
manipulate
The
Bash
for
you
or
the
session
itself
for
you
and
it
in
order
to
do
that,
it
needs
to
be
the
parent.
So
basically
you
have
then
this
hierarchy
chain,
where
you
have
the
normal
shell,
where
you
started
that
started
QB,
then
you
have
the
QB
process
inside
and
then
that
starts
another
bash
and
it
tries
to
hide
that
by
default
by
making
just
look
the
by
making
the
batch
Loop
the
same,
but
for
this
demo
I
just
wanted
to
show
it
to
you.
A
B
A
We
go
into
Simon's
fun
cluster
here,
so
just
again:
Cube
CTA
config
context.
We
can
see
the
bottom
one
is
in
Simon's
fun
cluster,
but
the
top
one
will
stay
in
uat
environment.
So
this
does
allow
us
to
be
in
different
clusters
or
different
name
spaces
at
the
same
time
using
different
shell
sessions
and
that,
of
course,
from
a
functionality
perspective,
at
least
for
me,
was
a
huge
win.
A
The
other
part
is,
it
also
is,
in
my
opinion,
a
bit
resource
hungry,
because
if
you
think
about
it
you
have
the
parent
shell,
then
you
have
the
QB
process,
and
then
you
have
the
child
of
QB,
just
for
like
manipulating
a
config
or
like
an
environment.
Variable
I
find
that
not
nice
and
then
there's
also
stuff
like
and
you
have
nested
shells.
A
A
Try
to
solve
this
problem
now,
I'm
going
to
demo
it
to
you
first
and
then
I
will
show
you
how
I
solve
this
problem,
but
let's
go
for
the
demo
first,
so
you
can
see
conf
and
by
the
way,
I
would
really
love
a
star.
It's
at
15
Stars,
the
other
one
had
her
like
at
a
thousand.
That
would
be
really
cool,
but
I'm
gonna
show
it
to
you
now.
A
So
let's
say
we
are
so
we
are.
We
are
in
the
top
pane
here.
So
if
we
run
concept,
you
will
see
I
actually
built
in
a
little
pop-up
dialogue.
So
no
fzf
required
on
your
machine.
If
you
don't
like
it,
but
it
can
also
do
fuzzy
if
I
am
remember
correctly
yep,
so
Simon's
fun
plaster.
So
we
are
in
Simon's
fun
cluster
that
work.
That
also
went
reasonably
fast,
and
it
is
because,
if
we
Cube
config
now
it
just
sets
that
variable
like
it
doesn't
do
anything
else.
A
If
you
run
out
concept
here
and
let's
say
we
go
to
uat
environment
down
below
here
we're
in
uat
down
below,
and
if
we
go
up
here,
we
are
still
in
Simon's
fun
cluster.
So
it
does
do
that.
It
allows
you
to
have
these
two
parts
and
it
allows
you
to
be
in
different
shells.
A
This
maybe
now
raises
the
question:
how
is
it
so
fast
and
we
kind
of
have
the
answer?
It
doesn't
need
to
spawn
a
new
shell
and
then
I
think
everyone
who
has
children
knows
what
comes
next
is
why
don't
we
need
to
spawn
a
new
shell
and
I've
already
mentioned
that?
Usually
a
child
process
cannot
make
changes
to
its
parent
process.
A
So
you
cannot
just
say:
hey
my
binary,
that
is
running
that
cannot
set
the
cube
config
for
the
parent
and
the
parent
is
the
shell
that
you
are
using,
and
that
is
where
you
would
want
to
set
the
cube
config.
So
it
cannot
do
that
right.
Well,
yes,
but
actually
no,
there
is
a
way
to
do
it
and
it's
if
you
abuse
a
bit
bash
and
that
shell
functions
and
what
that
means
more
precisely,
is
Bash
or
that
shell
functions
that
are
sourced
in
the
parent.
A
These
can
make
changes
to
the
parent
shell
like
it
is
actually
possible
for
this
and
By
changes,
I
mean
at
least
it
is
possible
to
set
environment
variables,
which
is
essentially
all
we
want.
So
let's
have
a
closer
look
into
this.
What
exactly
is
confident
the
binary
I
just
showed
there
is
the
binary
part
that
is
named
confgo
and
that
does
all
the
heavy
lifting.
A
In
the
background
that
you
see
like
manipulating
the
files
copying,
the
files
merging
different
files,
there's
all
done
by
confgo,
but
there's
also
conf,
which
is
like
a
bash
or
that
shell
function-
that
all
it
does
is
it
calls
conf,
go
waits
for
the
output
and
if
the
output
contains
a
certain
string,
it
is
going
to
export
cubeconfig
to
it.
So
whenever
you
run
conf
set,
it's
actually
just
going
to
talk
with
conf.
The
shell
wrapper
is
not
gonna
talk
directly
with
the
binary,
and
that
is
the
big
trick.
A
But
before
now,
I
just
keep
spamming
you
with
new
slides
and
complicated
graphs,
I'm
just
going
to
show
it
to
you
what
it
looks
like
and
what
that
actually
means,
then
for
the
end
user.
A
A
If
you
run
this,
you
will
actually
see
what
the
conf
function
looks
like
and
we're
going
to
go
through
it
step
by
step,
I'm
going
to
explain
it
a
bit.
So
this
just
says:
okay,
we
want
a
bash
function
or
that
shell
function,
that's
called
conf.
It's
then
just
gonna
run
confgo
and
it's
just
going
to
pass
in
all
the
arguments
that
you
gave
to
conf,
and
it
saves
that
in
the
result
of
the
of
this
variable
so
and
then
what
we
just
do
is
we
look.
A
A
This
here
is
just
some
shell
stuff,
but
basically
it's
the
it
says
that
split
out,
cubeconfig
change
out
of
this
one
is
is
I
would
just
take
in
the
path
that
comes
after
a
cube,
config
change,
so
confgo
essentially
returns
Q,
configs
change,
then
a
colon
and
then
a
slash,
Simon's
cluster.yammer,
for
example,
and
it
also
has
like
a
cleanup
function
to
clean
up
unnecessary
parts
of
it.
A
In
addition,
I
would
like
to
mention
that
conf
also
needs
to
maintain
its
own
store
to
do
some
of
the
magic
that
we
just
saw
and
for
this
I've
shipped
a
con
import
command.
That
by
the
way,
can
also
import
just
multiple
configs,
globbing
or
all
of
these
parts,
so
we
just
run
content
import.
A
For
that
so
yeah,
that's
what
it
how
it
works,
however,
I
think
it's
rather
elegantly
done
for
the
end
user,
I
hope,
at
least
because
if
you
want
to
install
conf
today,
which
of
course
I
recommend
that
you
do
that.
Next,
you
just
install
the
binary
and
then
basically
in
your
RC
file,
you
just
run
source
and
then
the
output
of
the
command,
so
I
think
that
is
for
the
setup
effort
reasonable
and
after
that
you
can
just
run
a
conf.
A
In
addition,
there's
some
other
things.
I
would
like
to
mention
that
are
optional,
as
we
have
like
a
couple
more
minutes
left.
So
you
can
also
it
also
supports
Auto
completion
like
the
tab
completion
you
saw.
So
if
you
do
like
cons,
set
oops
set
and
then
Simon
and
then
you
see
it
autocomplete,
so
you
can
also
tap
tap
through
it.
Without
any
issues
or
maybe
I
do
uat,
and
then
you
see
it
just
tap
completes
and
it
works.
Also
for
that
shell
and
Bash.
A
It
also
allows
you
to
set
a
default
Cube
config.
Every
time
you
open
a
new
session
or
set
the
the
cube
config
you
used
for
the
last
session.
So
if
you
just
if
you
just
do
something
like
this,
so
if
let's
say
I
spawn
a
new
split
here,
this
will
also
be
in
uat
environment,
because
that
is
the
country
last
used.
B
A
Yeah
with
that
I
like
to
announce
conf
is
now
in
beta.
There
will
be
a
lot
of
things,
I
think
to
iron
out
over
the
time,
just
because
different
clusters
do
take
different
yaml
formats,
different
operating
systems,
pars
like
colors
differently
in
terminals,
past
tables
differently
and
terminals,
but
yeah
I
would
really
love
for
you
guys
to
check
it
out.
Yeah,
put
up
some
issues
or
like
leave
some
feedback.
Of
course,
some
PRS.