Projects:Kubernetes: verschil tussen versies

Naar navigatie springen Naar zoeken springen
1.282 bytes toegevoegd ,  28 mrt 2019
Regel 1.056: Regel 1.056:


Now, let's make our own Docker image, push it, and start it in a Pod!
Now, let's make our own Docker image, push it, and start it in a Pod!
Here's an example Dockerfile that runs a tiny Perl-based webserver that always responds with its own hostname:
<pre>
$ cat Dockerfile
FROM ubuntu:bionic
RUN apt-get update \
&& apt-get install -y libmojolicious-perl \
&& rm -rf /var/lib/apt/lists/*
# Normally, you'd use COPY here, but I wanted to keep this in one file
RUN echo "#!/usr/bin/env perl"                      >>/app.pl \
&& echo "use Mojolicious::Lite;"                    >>/app.pl \
&& echo "get '/' => sub {"                          >>/app.pl \
&& echo "  shift->render(text => 'Hello World!'); " >>/app.pl \
&& echo "};"                                        >>/app.pl \
&& echo "app->start;"                              >>/app.pl \
&& chmod +x /app.pl
EXPOSE 3000
CMD ["/app.pl", "daemon", "-l"]
$ docker build -t kuberegistry.sjorsgielen.nl/helloworld:latest .
$ docker push kuberegistry.sjorsgielen.nl/helloworld:latest
</pre>
At this point, you should be able to write a Deployment, Service and Ingress for this application, using the examples above. <code>kubectl apply</code> should then start the Pod, Traefik should route the service and whatever host/path you configured should quickly be reachable and respond with "Hello World". We've created our own image and ran it on your cluster!


= To do =
= To do =

Navigatiemenu