Kubernetes question on a local Mac machine. Is min...
# general
m
Kubernetes question on a local Mac machine. Is minikube the same as the Kubernetes cluster that now ships with Docker’s app? I mean, can I use Docker’s Kubernetes cluster as a drop-in replacement for minikube? I’m debugging a deployment error (a timeout when creating a
k8s.core.v1.Service()
) and wondering if there’s a problem linked to the
isMinikube
setting.
g
No the Docker-for-Mac k8s cluster is not the same as Minikube. I mostly use DfM myself for development, but there are differences in what gets deployed by default
m
Thanks @gorgeous-egg-16927. I keep getting timeout errors (with or without using
"ClusterIP"
when trying to allocate a local IP. For example with the Guestbook example code. Using the Docker for Mac k8s cluster. I’ll try minikube next.
c
@miniature-potato-84713 in DfM they populate
hostname
instead of the IP in the
.status
gield
m
Hmm, ok, I’ll poke around. (I’m just starting to learn all that stuff.) So you’re saying that I need to tailor the Pūlumi code to the Kubernetes flavor I write it for—minikube, DfM, ECS?
g
Not generally, but perhaps for particular edge cases. If you have an example program that's not working, we can help troubleshoot
m
@gorgeous-egg-16927, The Guestbook example from your example repo…
c
@miniature-potato-84713 oh sorry I missed the actual quesiton.
Yes, if you’re running minikube or DfM you need to set
isMinikube
to true.
otherwise it will wait for a load balancer to be provisioned, which presumably your local machine cannot do. 🙂
m
@creamy-potato-29402, that’s what I thought but I still get the timeout.
c
can you post the code?
m
c
oh lol someone changed the code and didn’t update the docs
oh wait….
let me try it.
m
Ok
c
@miniature-potato-84713 it is the frontend service that’s failing, right?
m
Yes.
c
Copy code
$ minikube start
There is a newer version of minikube available (v0.33.1).  Download it here:
<https://github.com/kubernetes/minikube/releases/tag/v0.33.1>

To disable this notification, run the following:
minikube config set WantUpdateNotification false
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
E0206 16:54:35.569372   74404 start.go:174] Error starting host: Error starting stopped host: Error setting up host only network on machine start: host-only cidr conflicts with the network address of a host interface.

 Retrying.
E0206 16:54:35.569881   74404 start.go:180] Error starting host:  Error starting stopped host: Error setting up host only network on machine start: host-only cidr conflicts with the network address of a host interface
ugh
computers were a mistake.
👍 1
m
Have you tried it with Kubernetes that runs in Docker for Mac?
c
I’ve never tried dfm
installing
@miniature-potato-84713 in the meantime, can you show me what the result of
kubectl get
is?
for htat object
m
One moment, let me
up
first
@creamy-potato-29402, still noodling… waiting for the timeout
As for
get
which resource type do you want?
c
the service
hmm this worked for me.
m
Currently
Copy code
frontend-aqczm1da        LoadBalancer   10.98.147.145   <pending>     80:32229/TCP   9m
Wait
Loadbalancer?
Let me try again.
guestbook:isMinikube: "true"
c
is that the name of your stack?
pulumi stack ls
what platform are you on
m
Mac
c
oh duh lol sorry
Yeah this works both ways for me
m
up
again, making sure that the config says it’s a minikube (i.e. don’t use the load balancer). But you mentioned earlier the
in DfM they populate
hostname
instead of the IP in the
.status
gield
which would mean that I shouldn’t use
"clusterIP"
, correct?
c
this shouldn’t affect you, if you’re timing out
isMinikube
should only decide whether the service should be type clusterIP or not
can you run
pulumi config set isMinikube true
and then
pulumi config
and tell me the output?
m
Copy code
KEY                   VALUE
guestbook:isMinikube  true
That’s what’s noodling right now through
pulumi up
c
Right, I just want to confirm that your stack is actually called
guestbook
that’s after you ran exactly that command, right?
m
Yeah 😉
Copy code
pulumi-examples/kubernetes-ts-guestbook/components > pulumi config
KEY                   VALUE
guestbook:isMinikube  true
c
ok, so when you
get -o yaml
the service object you’re waiting on, what does it show?
m
Copy code
> kubectl get services
NAME                     TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
frontend-cjxb1rpy        LoadBalancer   10.105.151.196   <pending>     80:32503/TCP   6m
redis-master-7w2eedl3    ClusterIP      10.102.106.173   <none>        6379/TCP       6m
redis-replica-wo7gjc3z   ClusterIP      10.101.191.1     <none>        6379/TCP       6m
Again with the LB
c
wtf
m
Copy code
> kubectl get service frontend-cjxb1rpy -o yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    <http://pulumi.com/autonamed|pulumi.com/autonamed>: "true"
  creationTimestamp: 2019-02-07T01:13:25Z
  name: frontend-cjxb1rpy
  namespace: default
  resourceVersion: "80631"
  selfLink: /api/v1/namespaces/default/services/frontend-cjxb1rpy
  uid: 91d0f047-2a75-11e9-a4f9-025000000001
spec:
  clusterIP: 10.105.151.196
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 32503
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: frontend
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer: {}
c
can you change it to:
Copy code
let frontend = new k8sjs.ServiceDeployment("frontend", {
    replicas: 3,
    image: "<http://gcr.io/google-samples/gb-frontend:v4|gcr.io/google-samples/gb-frontend:v4>",
    ports: [80],
    allocateIpAddress: true,
    isMinikube: true
});
just to be sure
I like JUST tried this, this should def. work.
m
Destroy the current stack?
c
nah, just change that one thing
just copy+paste into the file.
m
Ok, one moment. The
up
is still noodling…
Or should I ctrl-c it?
Oh
Done 🙂
c
do that
m
One moment
c
k8s provider is really good at recovering
not all the providers do, the AWS provider for example makes you wait.
k8s will just quite immediately.
m
Ok, changed to hardwired minikube…
up
again…
Worked like a charm.
Copy code
Outputs:
  + frontendIp: "10.99.213.188"

Resources:
    +-1 replaced
    9 unchanged

Duration: 15s
c
ok so
isMinikube
is set incorrectly
pulumi config set isMinikube true
is not the same thing as
pulumi config set guestbook:isMinikube true
I’m guessing your stack is not called
guestbook
m
ARGH!
c
pulumi stack ls
m
testbook
vs
guestbook
Let me check the docs.
c
lol
welp.
m
pulumi config
KEY VALUE guestbook:isMinikube true
pulumi stack ls
NAME LAST UPDATE RESOURCE COUNT URL testbook* 1 minute ago 11 https://app.pulumi.com/jenstroeger/guestbook-easy/testbook
c
lol that would do it
m
HAH!
Docs 😛
Copy code
$ pulumi stack init
Enter a stack name: testbook
and then
Copy code
pulumi config set guestbook:isMinikube <value>
Should I submit a PR?
c
that would be great.
m
And then
Copy code
$ pulumi up
Updating stack 'k8sjs-guestbook'
...
Yeah I think that’s a bit inconsistent here 😉
c
yeah that’s our bad
someday we will automate the docs.
m
Phew!
Great to have a scapegoat that’s not me.
c
When in doubt, blame the CEO. 😉 who just so happens to have written this example.
m
Well thanks @big-piano-35669. I think you owe me a cookie next time I’m in town 😄 @creamy-potato-29402, should I update the
up
output as well?
c
to the readme?
Sure, if you like
m
Yes. I’m running the example front-to-back (well, trying to) and the output has changed since the README was written.
@creamy-potato-29402 Could it be that it should be
Copy code
let config = new pulumi.Config("guestbook");
c
nah
you want it to be the name of the stack
m
Because I had the same issue
c
pulumi config set isMinikube true
will set it to true independent of what your stack is called.
oh?
m
Copy code
> pulumi config
KEY                   VALUE
guestbook:isMinikube  true
> pulumi stack ls
NAME        LAST UPDATE  RESOURCE COUNT  URL
guestbook*  in progress  10              <https://app.pulumi.com/jenstroeger/guestbook-easy/guestbook>
c
can you try the command above and see what happens?
m
This is getting more confusing now… where does the
guestbook-easy
come from?
c
uh
I confess that I do not know.
m
Copy code
>  pulumi stack init
Enter a stack name: guestbook
Created stack 'guestbook'

> pulumi config set guestbook:isMinikube true

> pulumi up
Previewing update (guestbook):

     Type                                Name                      Plan
 +   pulumi:pulumi:Stack                 guestbook-easy-guestbook  create
Huh?
c
don’t know.
sorry
I would like to see what happens if you omit the
guestbook:
from the
pulumi config set
m
Copy code
> cat Pulumi.yaml 
name: guestbook-easy
runtime: nodejs
description: Kubernetes Guestbook example based on <https://kubernetes.io/docs/tutorials/stateless-application/guestbook/>
template:
  config:
    isMinikube:
      description: Whether you are deploying to minikube
      default: true
c
must be the name of the app
m
You’ll see the problem in the diff. Thank you for your help!
Although I can’t open that
10.105.48.30
but maybe I don’t care right now.
c
@miniature-potato-84713 that’s because it’s a cluster-internal IP address, isn’;t it?
m
Yup, but the example is somewhat incomplete in that it doesn’t expose that IP.
c
hmm, sorry, I’m confused. if the service is type clusterIP then it should NEVER expose a public IP, no?
m
Yeah sorry.
What I mean is that the example doesn’t show how to get from that cluster to the website shown in the picture. I think earlier today I ran through similar examples and used
kubectl proxy
c
that’s true.
m
So I am not sure if that can be added to the Pulumi program, or can only be done from `kubectl`… (You’ve noticed: I’m learning, this is all new to me.)
c
it kind of can!
this example will gate a multi-stage rollout on prometheus checks.
for local dev it does port forwarding.
this is NOT what you want to do in prod but you get the point.
m
Ah yes 👍
I am so out of my league here 😄
c
in fairness this “league” was made up like a couple months ago lol
so who is in the league, exactly
m
You guys more so than I am, that’s for sure. I usually operate more in the OS/compiler guts than in these lofty heights of the stack… getting dizzy here from the view and thin air. Hey, is this the same prometheus we’re talking about? https://dramatiq.io/advanced.html#prometheus-metrics
c
yes.
m
Huh neat.
c
yeah this is really stretching the possibilities.