> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/services/add-inline-manifests-using-file-store.md).

# Add inline service files using file store

Store Kubernetes manifests and other service files in the Harness File Store and select them in a service

{% hint style="info" %}
This feature is in Beta[^1] and requires enablement. [View all early access features.](/release-notes/features.md)

{% @harness-feature-flag-access/request-feature-flag-access module="continuous-delivery" pagePath="continuous-delivery/use-continuous-delivery/cd-building-blocks/services/add-inline-manifests-using-file-store" featureFlags="%5B%7B%22name%22%3A%22Remove%20comments%20from%20values.yaml%20with%20escape%20characters%22%2C%22key%22%3A%22CDS\_REMOVE\_COMMENTS\_FROM\_VALUES\_YAML\_WITH\_ESCAPE\_CHARACTERS%22%2C%22status%22%3A%22BETA%22%2C%22description%22%3A%22Handles%20special%20characters%20such%20as%20single%20quotes%2C%20double%20quotes%2C%20or%20backslashes%20in%20values.yaml%20so%20the%20parser%20does%20not%20add%20control%20characters%20that%20fail%20the%20pipeline.%22%7D%5D" %}
{% endhint %}

File Store is a hierarchical file manager in Harness for managing configuration files used in pipelines. Use it to store files in Harness and select them in your services. At deployment runtime, Harness uses the files from the Harness File Store.

With File Store, you can perform the following standard file manager tasks:

* Create and edit folders and files at the account, organization, or project level.
* Upload existing configuration files from your machine to a folder in File Store.
* Select configuration files or folders for deployments.

You can use a combination of File Store and remote repos for your configuration files. You are not limited to one method. File Store lets you share files with your team without managing remote repositories.

You can use [Kubernetes manifests](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-kubernetes-category/define-kubernetes-manifests.md) and other configuration files in Git repositories or in the Harness File Store. If you use a Git repository, Harness fetches files from the remote repo during deployment runtime.

For Kubernetes, the following configuration files are supported for File Store:

* Kubernetes manifest
* Helm chart
* OpenShift template and OpenShift parameters
* Kustomize and Kustomize patches

Go to the following topics for Kubernetes deployment background:

* [Kubernetes CD quickstart](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-cd-quickstart.md)
* [Kubernetes deployments overview](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-deployments-overview.md)
* [Add container images as artifacts for Kubernetes deployments](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-kubernetes-category/add-artifacts-for-kubernetes-deployments.md)

Other configuration files for other integrations, such as Azure Web Apps, are supported for the integrations available in your account. You can access File Store from **Project Setup** in Harness or using the **Add Manifest** step during pipeline creation.

***

## What you will learn from this topic

* How to [start a pipeline](#start-a-pipeline) and [add a Deploy stage](#add-a-deploy-stage)
* How to [create a Kubernetes service](#create-the-harness-service) that uses File Store manifests
* How to [add Kubernetes manifests and values.yaml](#add-kubernetes-manifests-and-valuesyaml-to-file-store) to File Store
* How to [select File Store files](#select-kubernetes-manifests-and-the-valuesyaml-file-from-file-store) in the service
* How to [reference File Store files with expressions](#reference-files-in-the-file-store-using-an-expression)

***

## Before you begin

* **Harness project**: A Harness project where you can create pipelines and services. Go to [What is a project?](https://developer.harness.io/docs/platform/get-started/harness-ui-overview#projects) to understand project setup.
* **File Store permissions**: Account Admin role for read and write access to modify folders and files. The Account Viewer role allows you only to view folders and files.
* **Kubernetes service familiarity**: Go to [Create services](/continuous-delivery/use-continuous-delivery/cd-building-blocks/services/create-services.md) to create services, and go to [Define Kubernetes manifests](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-kubernetes-category/define-kubernetes-manifests.md) for manifest options.

***

## Important notes

Keep the following limits in mind when you use File Store:

* File Store requires that you have the Account Admin role for read and write access to modify folders and files. The Account Viewer role allows you to only view folders and files.
* You can upload only a single file into the File Store folder. Support for uploading multiple configuration files concurrently is not available.
* The maximum file size cannot exceed 100MB.

***

## Start a pipeline

Perform the following steps to create a pipeline:

1. In Harness Manager, select **Pipelines**, then select **New Pipeline**.
2. Enter a name in **Create new Pipeline**, then select **Start**.

***

## Add a Deploy stage

For steps on adding a stage, go to [Add a stage](https://developer.harness.io/docs/platform/pipelines/add-a-stage).

Perform the following steps to add a Deploy stage:

1. Click **Add Stage**, then select **Deploy**.
2. Name the stage, and select what you want to deploy. For example, select **Service**.
3. Select **Set Up Stage**. The new stage settings appear.

***

## Create the Harness service

In **Service**, you can define or select the service and service definition.

Perform the following steps to create the service:

1. In **Specify Service**, select **New Service**, enter a name for this service, then select **Save**.
2. Select a Kubernetes service, or create a new service for Kubernetes.
3. For **Service Definition**, select **Kubernetes**.

To add your manifests, go to **Manifests** in **Service Definition**.

***

## Add Kubernetes manifests and values.yaml to File Store

You can create folders in File Store, add manifests to those folders, and Harness uses them at runtime.

The following example creates a folder called `CD_Manifests` for three manifests (`deployment.yaml`, `service.yaml`, and `namespace.yaml`) and a folder named `Templates` for the `values.yaml` file. In the blank file that appears for each of these manifests in File Store, you can copy the contents of a sample manifest file into each blank file and save them in File Store.

{% hint style="info" %}
**Folder layout**

You can create a single folder and save all of the manifest files in that folder. Or you can store the `values.yaml` file in a folder that is separate from a `Templates` folder where the `deployment.yaml`, `service.yaml`, and `namespace.yaml` files are stored.
{% endhint %}

{% hint style="warning" %}
**Special characters in values.yaml**

When using special characters such as single quotes (`'`), double quotes (`"`), or backslashes (`\`) in the `values.yaml` file, the parser can add control characters and cause the pipeline to fail.

Enable the feature flag `CDS_REMOVE_COMMENTS_FROM_VALUES_YAML_WITH_ESCAPE_CHARACTERS` to handle these characters. Contact [Harness Support](mailto:support@harness.io) to enable the flag.
{% endhint %}

Perform the following steps to add manifests to File Store:

{% stepper %}
{% step %}

### Open Add Manifest

In **Manifests**, select **Add Manifest**.
{% endstep %}

{% step %}

### Select Kubernetes manifest and Harness store

In **Specify Manifest Type**, select **K8s Manifest**, then select **Continue**.

In **Specify K8s Manifest Store**, select **Harness**, then select **Continue**.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-89bbab58e5f9e71fd232755de9d8c7a8a2559a50%2Fadd-inline-manifests-using-file-store-10.png?alt=media)
{% endstep %}

{% step %}

### Create folders and manifest files

In the **Manifest Details** dialog, enter a name for this manifest. For example, `CD_Manifests`.

In the field under **File Store**, click the down arrow.

In the **Create or Select an Existing Config File** dialog, select **Project**.

Select **New**, select **New Folder**, enter a name for the folder (for example, `Templates`), then select **Save**.

With this new folder selected, select **New File**.

Enter the file name `deployment.yaml`, select **Manifest for File Usage**, then select **Create**.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-cf58dc961d1ed5ed1c16f04a2ab2f46a346a0199%2Fadd-inline-manifests-using-file-store-11.png?alt=media)

When Harness displays the blank `deployment.yaml` manifest, copy the contents of the sample `deployment.yaml` manifest, paste it in the blank file, then select **Save**.

Create the `namespace.yaml` and `service.yaml` manifests by copying, pasting, and saving the manifests in File Store.
{% endstep %}

{% step %}

### Add values.yaml

Select **New**, then select **New Folder**, name the new folder (for example, `Files`), then select **Create**.

With the `Templates` folder selected, select **New**, then select **New File**.

In **New File**, enter `values.yaml` as the manifest name, select **Manifest for File Usage**, then select **Create**.

When the blank `values.yaml` manifest appears, copy the contents of the `values.yaml` file, paste it in the blank file, then select **Save**.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-0b0b60c929366c0d796b23333ec6c10439053f51%2Fadd-inline-manifests-using-file-store-12.png?alt=media)
{% endstep %}
{% endstepper %}

You have completed adding folders and manifests to File Store.

***

## Select Kubernetes manifests and the values.yaml file from File Store

You can select and apply the File Store folder with the Kubernetes manifests and the `values.yaml` file to your pipeline.

Perform the following steps to select the files:

1. In **File Store**, select the `CD_Manifests` folder that contains the manifests, then select **Apply Selected**. File Store in **Manifest Details** is populated with the `/CD_Manifests` folder and the manifests within that folder.
2. In **Manifest Details**, select `values.yaml`.
3. In **Create or Select an Existing Config file**, select **Project**, and navigate to the `CD_Manifests/Templates` folder. Select `values.yaml`, then select **Apply Selected**.
4. Select **Submit**. The manifests that you created for this service are applied to the service.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-e8a9cb7c673c8646e50fbcf6d86bcecb53246237%2Fadd-inline-manifests-using-file-store-13.png?alt=media)

***

## Example manifests

Manifests can use hardcoded values or a values YAML file and templating. Harness supports Go templating. Go to [Example Kubernetes manifests using Go templating](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-k8s-ref/example-kubernetes-manifests-using-go-templating.md) to review templating patterns.

Use the following manifests to copy into your blank manifest files in File Store and save them. Then customize them for your environment, and apply them to your pipelines.

<details>

<summary>values.yaml</summary>

```yaml
name: example  
replicas: 2  
  
image: <+artifact.image>  
# dockercfg: <+artifact.imagePullSecret>
  
createNamespace: true  
namespace: <+infra.namespace>  
  
# Service Type allow you to specify what kind of service you want.
# Possible values for ServiceType are:
# ClusterIP | NodePort | LoadBalancer | ExternalName
serviceType: LoadBalancer  
  
# A Service can map an incoming port to any targetPort.
# targetPort is where application is listening on inside the container.
servicePort: 80  
serviceTargetPort: 80  
  
# Specify all environment variables to be added to the container.
# The following two maps, config and secrets, are put into a ConfigMap
# and a Secret, respectively.
# Both are added to the container environment in podSpec as envFrom source.
env:  
  config:  
    key1: value10  
  secrets:  
    key2: value2
```

</details>

<details>

<summary>deployment.yaml</summary>

```yaml
{{- if .Values.env.config}}  
apiVersion: v1  
kind: ConfigMap  
metadata:  
  name: {{.Values.name}}  
data:  
{{.Values.env.config | toYaml | indent 2}}  
---  
{{- end}}  
  
{{- if .Values.env.secrets}}  
apiVersion: v1  
kind: Secret  
metadata:  
  name: {{.Values.name}}  
stringData:  
{{.Values.env.secrets | toYaml | indent 2}}  
---  
{{- end}}  
  
{{- if .Values.dockercfg}}  
apiVersion: v1  
kind: Secret  
metadata:  
  name: {{.Values.name}}-dockercfg  
  annotations:  
    harness.io/skip-versioning: true  
data:  
  .dockercfg: {{.Values.dockercfg}}  
type: kubernetes.io/dockercfg  
---  
{{- end}}  
  
apiVersion: apps/v1  
kind: Deployment  
metadata:  
  name: {{.Values.name}}-deployment  
spec:  
  replicas: {{int .Values.replicas}}  
  selector:  
    matchLabels:  
      app: {{.Values.name}}  
  template:  
    metadata:  
      labels:  
        app: {{.Values.name}}  
    spec:  
      {{- if .Values.dockercfg}}  
      imagePullSecrets:  
      - name: {{.Values.name}}-dockercfg  
      {{- end}}  
      containers:  
      - name: {{.Values.name}}  
        image: {{.Values.image}}  
        {{- if or .Values.env.config .Values.env.secrets}}  
        envFrom:  
        {{- if .Values.env.config}}  
        - configMapRef:  
            name: {{.Values.name}}  
        {{- end}}  
        {{- if .Values.env.secrets}}  
        - secretRef:  
            name: {{.Values.name}}  
        {{- end}}  
        {{- end}}
```

</details>

<details>

<summary>service.yaml</summary>

```yaml
apiVersion: v1  
kind: Service  
metadata:  
  name: {{.Values.name}}-svc  
spec:  
  type: {{.Values.serviceType}}  
  ports:  
  - port: {{.Values.servicePort}}  
    targetPort: {{.Values.serviceTargetPort}}  
    protocol: TCP  
  selector:  
    app: {{.Values.name}}
```

</details>

<details>

<summary>namespace.yaml</summary>

```yaml
{{- if .Values.createNamespace}}  
apiVersion: v1  
kind: Namespace  
metadata:  
  name: {{.Values.namespace}}  
{{- end}}
```

</details>

***

## Reference files in the File Store using an expression

The expression `fileStore.getAsString()` can be used to fetch files in the File Store in a script or runtime input.

{% hint style="warning" %}
**Referenced by list**

Referencing files in a Shell Script step using the expressions `fileStore.getAsString()` or `fileStore.getAsBase64()` does not add the file to the **Referenced by** list, which makes the file prone to deletion even if it is actively used.
{% endhint %}

Use the following expression forms by scope:

* Project-level File Store: `fileStore.getAsString("/folder1/myfile.yaml")`.
* Org-level File Store: `fileStore.getAsString("org:/folder1/myfile.yaml")`.
* Account-level File Store: `fileStore.getAsString("account:/folder1/myfile.yaml")`.
* Base64 encoded: `fileStore.getAsBase64("account:/folder1/folder2/myfile")`.

{% hint style="info" %}
**Same file name in different folders**

You can create two files with the same name inside two different folders by using a different identifier for one of the files. The path of the file is constructed based on the name, not the identifier.
{% endhint %}

***

## Next steps

* [Define Kubernetes manifests](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-kubernetes-category/define-kubernetes-manifests.md): Compare File Store with Git-based manifest stores.
* [Example Kubernetes manifests using Go templating](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-k8s-ref/example-kubernetes-manifests-using-go-templating.md): Template manifests with values files.
* [Create services](/continuous-delivery/use-continuous-delivery/cd-building-blocks/services/create-services.md): Create and manage Continuous Delivery services.
* [Add a stage](https://developer.harness.io/docs/platform/pipelines/add-a-stage): Add Deploy and other stage types to a pipeline.

{% @harness-feedback/feedback %}

[^1]: Beta features are feature-complete but still being validated. Available on request.
