In this example, we run the Skipper server on the local machine and deploy to minikube, which also runs on the local machine.
Note | |
---|---|
The upgrade approach in 1.02 does not correctly handle the routing of HTTP traffic between versions, so the following representation may not be exactly accurate. |
The Spring Cloud Deployer for Kubernetes creates a service, a replication controller, and a pod for the app (or, optionally, a deployment). This is not an issue for apps that communicate over Messaging middleware and will be addressed in a future release.
Start the Skipper server with the --spring.config.location=skipper.yml
option. The YAML content follows:
spring: cloud: skipper: server: enableLocalPlatform: false platform: kubernetes: accounts: minikube: namespace: default
The repo list
command shows the experimental
and local
repositories, since they are configured by default, as follows:
skipper:>repo list ╔════════════╤═══════════════════════════════════════════════════════════╤═════╤═════╗ ║ Name │ URL │Local│Order║ ╠════════════╪═══════════════════════════════════════════════════════════╪═════╪═════╣ ║experimental│http://skipper-repository.cfapps.io/repository/experimental│false│0 ║ ║local │http://d4d6d1b6-c7e5-4226-69ec-01d4:7577 │true │1 ║ ╚════════════╧═══════════════════════════════════════════════════════════╧═════╧═════╝
The package search
command shows the Name, the Version, and the Description, as follows:
skipper:>package search ╔═════════════════╤═══════╤════════════════════════════════════════════════════════════════════════════════╗ ║ Name │Version│ Description ║ ╠═════════════════╪═══════╪════════════════════════════════════════════════════════════════════════════════╣ ║helloworld │1.0.1 │The app has two endpoints, /about and /greeting in Portuguese. Maven resource. ║ ║helloworld │1.0.0 │The app has two endpoints, /about and /greeting in English. Maven resource. ║ ║helloworld-docker│1.0.1 │The app has two endpoints, /about and /greeting in Portuguese. Docker resource.║ ║helloworld-docker│1.0.0 │The app has two endpoints, /about and /greeting in English. Docker resource. ║ ╚═════════════════╧═══════╧════════════════════════════════════════════════════════════════════════════════╝
The platform list
command shows which platforms the server has been configured with — in this case, one Kubernetes namespace.
Disabling the local platform by setting the enableLocalPlatform
property to false
causes the default local
platform to not appear.
skipper:>platform list ╔════════╤══════════╤══════════════════════════════════════════════════════════════════════════════════════╗ ║ Name │ Type │ Description ║ ╠════════╪══════════╪══════════════════════════════════════════════════════════════════════════════════════╣ ║minikube│kubernetes│master url = [https://192.168.99.100:8443/], namespace = [default], api version = [v1]║ ╚════════╧══════════╧══════════════════════════════════════════════════════════════════════════════════════╝
Now we can install the Hello World app (specifically, the Docker-based artifact), as follows:
skipper:>package install --release-name helloworldk8s --package-name helloworld-docker --package-version 1.0.0 --platform-name minikube --properties spec.deploymentProperties.spring.cloud.deployer.kubernetes.createNodePort=32123 Released helloworldk8s. Now at version v1.
We use the --platform-name minikube
command option, because the default value of that shell option is default
.
You can register a platform under the default
name when installing Skipper, but it is a best practice to specify the target platform name.
You can monitor the process by using the release status
command, as follows:
skipper:>release status --release-name helloworldk8s ╔═══════════════╤══════════════════════════════════════════════════════════════════════════════════════════════════╗ ║Last Deployed │Wed Oct 25 17:34:24 EDT 2017 ║ ║Status │DEPLOYED ║ ║Platform Status│The applications are being deployed. ║ ║ │[helloworldk8s-helloworld-docker-v1], State = [helloworldk8s-helloworld-docker-v1-cch68=deploying]║ ╚═══════════════╧══════════════════════════════════════════════════════════════════════════════════════════════════╝
Eventually, the Platform Status says, All applications have been successfully deployed.
Note that the DEPLOYED
status in the preceding example indicates that Skipper has told the platform to deploy.
Skipper does not keep track of the intermediate states ('deploying' or 'deleting').
A kubectl pods
command now shows a new listing for this deployed application, as follows:
$ kubectl get pods NAME READY STATUS RESTARTS AGE helloworldk8s-helloworld-docker-v1-g8j39 0/1 Running 0 37s $ kubectl get service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE helloworldk8s-helloworld-docker-v1 10.0.0.202 <nodes> 8080:32123/TCP 41s kubernetes 10.0.0.1 <none> 443/TCP 57m
To get the URL of this app on minikube, use the minikube service
command, as follows:
$ minikube service --url helloworldk8s-helloworld-docker-v1 http://192.168.99.100:32123
You can now curl the greeting
endpoint and the about
endpoint, as shown in the following example:
$ curl http://192.168.99.100:32123/greeting Hello World! $ curl http://192.168.99.100:32123/about Hello World v1.0.0.RELEASE
The name of the application is based on the following convention: <release-name>-<package-name>-v<incrementing-counter>
.
Future releases will change this convention to correctly handle routing.
The package provides a means to template the application version, application properties, and deployment properties that are used to deploy the application to Kubernetes.
The manifest get
command shows the final YAML file, which is passed off to the Spring Cloud Deployer Library, as shown (with its output) in the following example:
skipper:>manifest get --release-name helloworldk8s --- # Source: template.yml apiVersion: skipper.spring.io/v1 kind: SpringCloudDeployerApplication metadata: name: helloworld-docker spec: resource: docker:springcloud/spring-cloud-skipper-samples-helloworld:1.0.0.RELEASE applicationProperties: deploymentProperties: spring.cloud.deployer.kubernetes.createNodePort: 32123
The format of the is inspired by the Kubernetes Resource file format. By looking at the manifest, you can see which Docker images were used and which properties were set before the final push to Kubernetes. A future release of Skipper will use the metadata values to support searching for releases based on those values.
Since it is somewhat awkward to specify multiple flattened out YAML values for the --properties
argument in the shell, you can also specify the location of a YAML file when installing or upgrading.
We use a YAML file when we update the release.
This application contains a Spring Boot
@ConfigurationProperty
named helloworld.greeting
, so we set that, along with a standard Spring Boot property: endpoints.sensitive=false
. We also bump the memory down to 768m from the default 1G.
The following listing shows all the settings:
spec: applicationProperties: endpoints.sensitive: false helloworld.greeting: yo deploymentProperties: spring.cloud.deployer.kubernetes.createNodePort: 32124 spring.cloud.deployer.memory: 768m
The following example shows the release upgrade
command and its output:
skipper:>release upgrade --release-name helloworldk8s --package-name helloworld-docker --package-version 1.0.0 --file /home/mpollack/helloworld-upgrade-k8s.yml helloworldk8s has been upgraded. Now at version v2.
The preceding command starts another instance of the hello world application.
If you do not specify --package-version
, it picks the latest version of the helloworld-docker
package.
You do not need to specify the --platform-name
as it is always where the current application was deployed.
The following example shows the kubectl get all
command and its output:
$ kubectl get all NAME READY STATUS RESTARTS AGE po/helloworldk8s-helloworld-docker-v1-g8j39 1/1 Running 0 2m po/helloworldk8s-helloworld-docker-v2-jz85l 0/1 Running 0 50s NAME DESIRED CURRENT READY AGE rc/helloworldk8s-helloworld-docker-v1 1 1 1 2m rc/helloworldk8s-helloworld-docker-v2 1 1 0 50s NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/helloworldk8s-helloworld-docker-v1 10.0.0.202 <nodes> 8080:32123/TCP 2m svc/helloworldk8s-helloworld-docker-v2 10.0.0.154 <nodes> 8080:32124/TCP 51s svc/kubernetes 10.0.0.1 <none> 443/TCP 59m
At this point, Skipper is looking to see if the health endpoint of the Boot application is OK.
The spring.cloud.skipper.server.strategies.healthcheck.timeoutInMillis
property sets the maximum time the upgrade process waits for a healthy app.
The default value is 5 minutes.
Skipper fails the deployment if it is not healthy within that time.
The spring.cloud.skipper.server.strategies.healthcheck.sleepInMillis
property sets how long to sleep between health checks.
The current upgrade strategy is simple: If the new app is healthy, the old app is removed. There is not a rolling upgrade option. All new apps are deployed and checked for health. Then any previous versions are removed. Future releases will have more flexible upgrade strategies, along with the introduction of the Spring Cloud State Machine project to orchestrate the update process.
You can now curl the greeting
endpoint and the about
endpoint, as follows:
$ curl http://192.168.99.100:32124/greeting yo $ curl http://192.168.99.100:32124/about Hello World v1.0.0.RELEASE
The release list
command shows the current DEPLOYED
and DELETED
release for every release name.
In the following example, there is only one entry:
skipper:>release list ╔═════════════╤═══════╤════════════════════════════╤════════╤═════════════════╤═══════════════╤═════════════╤═══════════════╗ ║ Name │Version│ Last updated │ Status │ Package Name │Package Version│Platform Name│Platform Status║ ╠═════════════╪═══════╪════════════════════════════╪════════╪═════════════════╪═══════════════╪═════════════╪═══════════════╣ ║helloworldk8s│2 │Wed Oct 25 17:36:16 EDT 2017│DEPLOYED│helloworld-docker│1.0.0 │minikube │ ║ ╚═════════════╧═══════╧════════════════════════════╧════════╧═════════════════╧═══════════════╧═════════════╧═══════════════╝
You can get the full history of the release using the history
command, as follows:
skipper:>release history --release-name helloworldk8s ╔═══════╤════════════════════════════╤════════╤═════════════════╤═══════════════╤════════════════╗ ║Version│ Last updated │ Status │ Package Name │Package Version│ Description ║ ╠═══════╪════════════════════════════╪════════╪═════════════════╪═══════════════╪════════════════╣ ║2 │Wed Oct 25 17:36:16 EDT 2017│DEPLOYED│helloworld-docker│1.0.0 │Upgrade complete║ ║1 │Wed Oct 25 17:34:24 EDT 2017│DELETED │helloworld-docker│1.0.0 │Delete complete ║ ╚═══════╧════════════════════════════╧════════╧═════════════════╧═══════════════╧════════════════╝
A more typical upgrade process is not to change application properties but to change the version of the application because the code has changed.
We can now upgrade the release to use a new Docker artifact, version 1.0.1, which also corresponds to version 1.0.1 of the helloworld
Skipper package.
In the following example, we do not add any additional properties other than NodePort
:
skipper:>release upgrade --release-name helloworldk8s --package-name helloworld-docker --package-version 1.0.1 --properties spec.deploymentProperties.spring.cloud.deployer.kubernetes.createNodePort=32125 Released helloworldk8s. Now at version v3.
Note that the the current release’s property values, such as using 2G RAM or the greeting being yo
, are not carried over.
A future release will introduce a --reuse-properties
command option that will carry the current release properties over to the next release to be made.
You can monitor the status of the upgrade by using the status
command, as shown (with its output) in the following example:
skipper:>release status --release-name helloworldk8s ╔═══════════════╤══════════════════════════════════════════════════════════════════════════════════════════════════╗ ║Last Deployed │Wed Oct 25 17:41:33 EDT 2017 ║ ║Status │DEPLOYED ║ ║Platform Status│All applications have been successfully deployed. ║ ║ │[helloworldk8s-helloworld-docker-v3], State = [helloworldk8s-helloworld-docker-v3-sb59j=deployed] ║ ╚═══════════════╧══════════════════════════════════════════════════════════════════════════════════════════════════╝
A curl
command shows the following output:
$ curl http://192.168.99.100:32125/greeting Olá Mundo! $ curl http://192.168.99.100:32125/about Hello World v1.0.1.RELEASE
The following example shows the release history
command and its output:
skipper:>release history --release-name helloworldk8s ╔═══════╤════════════════════════════╤════════╤═════════════════╤═══════════════╤════════════════╗ ║Version│ Last updated │ Status │ Package Name │Package Version│ Description ║ ╠═══════╪════════════════════════════╪════════╪═════════════════╪═══════════════╪════════════════╣ ║3 │Wed Oct 25 17:41:33 EDT 2017│DEPLOYED│helloworld-docker│1.0.1 │Upgrade complete║ ║2 │Wed Oct 25 17:36:16 EDT 2017│DELETED │helloworld-docker│1.0.0 │Delete complete ║ ║1 │Wed Oct 25 17:34:24 EDT 2017│DELETED │helloworld-docker│1.0.0 │Delete complete ║ ╚═══════╧════════════════════════════╧════════╧═════════════════╧═══════════════╧════════════════╝
Next, we use the rollback
command to deploy an older version of the application.
Since we have the manifest for that version, we have all we need to redeploy an earlier release.
The following example shows the rollback command and its output:
skipper:>release rollback --release-name helloworldk8s --release-version 2
helloworldk8s has been rolled back. Now at version v4.
The history now shows a new v4
version, even though it is identical to the v2
version, as shown in the following example:
skipper:>release history --release-name helloworldk8s ╔═══════╤════════════════════════════╤════════╤═════════════════╤═══════════════╤════════════════╗ ║Version│ Last updated │ Status │ Package Name │Package Version│ Description ║ ╠═══════╪════════════════════════════╪════════╪═════════════════╪═══════════════╪════════════════╣ ║4 │Wed Oct 25 17:44:25 EDT 2017│DEPLOYED│helloworld-docker│1.0.0 │Upgrade complete║ ║3 │Wed Oct 25 17:41:33 EDT 2017│DELETED │helloworld-docker│1.0.1 │Delete complete ║ ║2 │Wed Oct 25 17:36:16 EDT 2017│DELETED │helloworld-docker│1.0.0 │Delete complete ║ ║1 │Wed Oct 25 17:34:24 EDT 2017│DELETED │helloworld-docker│1.0.0 │Delete complete ║ ╚═══════╧════════════════════════════╧════════╧═════════════════╧═══════════════╧════════════════╝
The curl
commands now shows the following:
$ curl http://192.168.99.100:32124/greeting yo $ curl http://192.168.99.100:32124/about Hello World v1.0.0.RELEASE