Create a Kubernetes Rolling Deployment (FirstGen)
This content is for Harness FirstGen. Switch to NextGen.
A rolling update strategy updates Kubernetes deployments with zero downtime by incrementally updating pods instances with new ones. New Pods are scheduled on nodes with available resources.
This method is similar to a standard Canary strategy, but different to Harness Kubernetes Canary strategy. The Harness Kubernetes Canary strategy uses a rolling update as its final phase. See Create a Kubernetes Canary Deployment for more information.
For a detailed explanation of Kubernetes rolling updates, see Performing a Rolling Update from Kubernetes.
Before You Begin
Review: What Workloads Can I Deploy?
See What Can I Deploy in Kubernetes?.
Multiple Managed Workloads
For Rolling Update deployments, you can deploy multiple managed workloads.
For Canary and Blue/Green Workflow deployments, only one managed object may be deployed per Workflow by default. You can deploy additional objects using the Apply Step, but it is typically used for deploying Jobs controllers.
You can specify the multiple workload objects in a single manifest or in individual manifests, or any other arrangement.For example, here is a Service Manifests section with two Deployment objects, each in their own manifest:
Here is the log from the deployment, where you can see both Deployment objects deployed:
apiVersion: apps/v1
kind: Deployment
metadata:
name: anshul-multiple-workloads-deployment
spec:
replicas: 1
selector:
matchLabels:
app: anshul-multiple-workloads
template:
metadata:
labels:
app: anshul-multiple-workloads
spec:
containers:
- name: anshul-multiple-workloads
image: registry.hub.docker.com/library/nginx:stable
envFrom:
- configMapRef:
name: anshul-multiple-workloads
- secretRef:
name: anshul-multiple-workloads
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: anshul-multiple-workloads-deployment-1
spec:
replicas: 3
selector:
matchLabels:
app: anshul-multiple-workloads
template:
metadata:
labels:
app: anshul-multiple-workloads
spec:
containers:
- name: anshul-multiple-workloads
image: registry.hub.docker.com/library/nginx:stable
envFrom:
- configMapRef:
name: anshul-multiple-workloads
- secretRef:
name: anshul-multiple-workloads
Step 1: Define Rollout Strategy
There are no mandatory Rolling Update–specific settings for manifests in the Harness Service. You can use any Kubernetes configuration in your Service Manifests section.
The default Rolling Update strategy used by Harness is:
RollingUpdateStrategy: 25% max unavailable, 25% max surge
If you want to set a Rolling Update strategy that is different from the default, you can include the strategy settings in your Deployment manifest:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
For details on the settings, see RollingUpdateDeployment in the Kubernetes API docs.
Step 2: Create Workflow
- In your Application containing a completed Service and Environment for the Rollout Deployment, click Workflows.
- Click Add Workflow. The Workflow dialog appears.
- In Name, enter a name for your Workflow.
- In Workflow Type, select Rolling Deployment.
- In Environment, select the Environment you created for your Kubernetes deployment.
- In Service, select the Service containing the manifest files you want to use for your deployment.
- In Infrastructure Definition, select the Infrastructure Definition where you want to deploy.
- When you are finished, the Workflow dialog will look like this example:
- Click SUBMIT. The new Workflow appears.
Step 3: Rollout Deployment Step
The Workflow generates the Rollout Deployment step automatically. There's nothing to update. You can deploy the Workflow.
The Rollout Deployment step includes the following options.
Manifest Options
Export Manifest
If you enable this option, Harness does the following at runtime:
- Downloads manifests (if remote).
- Renders manifests in logs.
- Performs a dry run unless the Skip Dry Run option is enabled.
- Export the deployment manifests to the variable
${k8sResources.manifests}
. - Does not deploy the manifests. To deploy the manifests, you must add another Kubernetes step of the same type (Canary, Rolling, Apply, Stage Deployment) an enable the Inherit Manifest option to deploy a copy of the exported manifests.
If Export Manifest is enabled, the manifests are not deployed. You can use the Inherit Manifest