Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions _data/home-content.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@



- title: CI/CD guides
icon: images/home-icons/guides.png
url: ''
links:
- title: Building your app
localurl: /docs/ci-cd-guides/packaging-compilation/
- title: Building Docker images
localurl: /docs/ci-cd-guides/building-docker-images/
- title: Accessing a Docker registry from Kubernetes cluster
localurl: /docs/ci-cd-guides/access-docker-registry-from-kubernetes/
- title: Working with Docker registries
localurl: /docs/ci-cd-guides/working-with-docker-registries/
- title: Adding config maps to namespaces
localurl: /docs/ci-cd-guides/add-config-maps-to-your-namespaces/
- title: Pull Requests and branches
localurl: /docs/ci-cd-guides/pull-request-branches/
- title: Pipelines for microservices
localurl: /docs/ci-cd-guides/microservices/
- title: Deploying to predefined environments
localurl: /docs/ci-cd-guides/environment-deployments/
- title: Previewing dynamic environments
localurl: /docs/ci-cd-guides/preview-environments/
- title: Helm best practices
localurl: /docs/ci-cd-guides/helm-best-practices/
- title: Templating for Kubernetes
localurl: /docs/ci-cd-guides/kubernetes-templating/
- title: Progressive Delivery
localurl: /docs/ci-cd-guides/progressive-delivery/


- title: Example catalog
icon: images/home-icons/tutorial.svg
url: ''
Expand Down Expand Up @@ -154,5 +185,6 @@






35 changes: 34 additions & 1 deletion _data/nav.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@



- title: CI/CD Guides
url: "/ci-cd-guides"
pages:
- title: Building your app
url: "/packaging-compilation"
- title: Building Docker images
url: "/building-docker-images"
- title: Accessing Docker registries from Kubernetes cluster
url: "/access-docker-registry-from-kubernetes"
- title: Working with Docker registries
url: "/working-with-docker-registries"
- title: Adding config maps to namespaces
url: "/add-config-maps-to-your-namespaces"
- title: Pull Requests and branches
url: "/pull-request-branches"
- title: Building microservices
url: "/microservices"
- title: Deploying to predefined environments
url: "/environment-deployments"
- title: Previewing dynamic environments
url: "/preview-environments"
- title: Progressive delivery
url: "/progressive-delivery"
- title: GitOps deployments
url: "/gitops-deployments"
- title: Helm best practices
url: "/helm-best-practices"
- title: Kubernetes templating
url: "/kubernetes-templating"




- title: Example catalog
Expand Down Expand Up @@ -266,6 +298,7 @@
url: "/csdp-cli"



- title: Installation
url: "/installation"
pages:
Expand All @@ -290,7 +323,6 @@
- title: Add Git Sources to to GitOps Runtimes
url: "/git-sources"


- title: Administration
url: "/administration"
pages:
Expand Down Expand Up @@ -378,3 +410,4 @@
url: "/sla"



127 changes: 127 additions & 0 deletions _docs/ci-cd-guides/access-docker-registry-from-kubernetes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: "Accessing Docker registry from Kubernetes cluster"
description: "Allow Kubernetes to pull Docker images from your registry"
group: ci-cd-guides
toc: true
---

Kubernetes deployments are based on a "pull" approach. When you deploy your application to a Kubernetes
cluster, instead of uploading the application itself, as in traditional deployments, Kubernetes pulls the Docker images to its nodes on its own.


{% include
image.html
lightbox="true"
file="/images/getting-started/quick-start-k8s/overview.png"
url="/images/getting-started/quick-start-k8s/overview.png"
alt="Kubernetes deployments"
caption="Kubernetes deployments"
max-width="80%"
%}

If your Docker images are in a public repository such as Docker Hub, Kubernetes can pull them right away. In most cases however your images are in a private Docker registry and Kubernetes must be given explicit access to it.

Use [Docker registry secrets](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/){:target="\_blank"} to give Kubernetes access to private Docker registries. When there is a deployment, each Kubernetes pod can pull Docker images directly from the target registry.

## Giving access to a Docker Registry via the UI

Codefresh allows you to easily create and pull secrets for your cluster.

1. In the Codefresh UI, set up an integration with your [Docker registry in Codefresh]({{site.baseurl}}/docs/integrations/docker-registries/).
Codefresh can work with any compliant Docker registry either in the cloud or behind the firewall.

1. To view the Kubernetes dashboard, from the Ops section in the sidebar, select [**Kubernetes Services**](https://g.codefresh.io/kubernetes/services/){:target="\_blank"}.
1. Click **Add Service**.
1. Do the following:
* Select your **Cluster** and **Namespace** from the respective lists.
* From the **Image Pull Secret** dropdown with all the pull secrets for the selected namespace, select **Create Registry Pull secret**.
* From the list of all the connected Docker registries in Codefresh, select the registry you want.
Codefresh automatically creates a secret for you.

{% include
image.html
lightbox="true"
file="/images/guides/kubernetes/create-secret.png"
url="/images/guides/kubernetes/create-secret.png"
alt="Create Pull Secret"
caption="Create Pull Secret"
max-width="80%"
%}


>The secret is created as soon as you select your Docker registry from the dropdown. There is no need to actually deploy anything from this screen for the changes to take effect.

{% include
image.html
lightbox="true"
file="/images/guides/kubernetes/secret-dropdown.png"
url="/images/guides/kubernetes/secret-dropdown.png"
alt="Docker Registry Access"
caption="Docker Registry Access"
max-width="80%"
%}

From now on, the cluster in this namespace can deploy Docker images from the selected registry.
To apply the changed secret, you don't really need to finish the deployment. Feel free to
close the screen and go to another Codefresh page.

>Codefresh automatically uses the secret you defined in all deployments that are performed via the UI by dynamically creating the correct manifests for you behind the scenes.
If you wish to use your own manifests, you need to include the secret yourself, as explained in the next section.


## Giving access to a Docker Registry with kubectl

You can also use the `kubectl` command directly to give access to a Docker registry.
As this method is not specific to Codefresh, read the [official kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/){:target="\_blank"}.


### Creating the Docker registry secret

The credentials depend upon the [type of registry]({{site.baseurl}}/docs/integrations/docker-registries/) you use.

- The Docker server to use is a domain such `gcr.io`, `azurecr.io`
- The username is your account username.
- The password is a specific Docker registry password or any other kind of token. You need to check the documentation of your registry provider for the exact details.

>Be sure to create the secret in the namespace in which your application will run.
Pull secrets are specific to a namespace. If you want to deploy to multiple namespaces, you need to create a secret for each one of them.

This is an example of creating a pull secret to the Azure registry. You can use the same command for any other private registry.

`Shell`
{% highlight sh %}
{% raw %}

export DOCKER_REGISTRY_SERVER=mysampleregistry.azurecr.io
export DOCKER_USER=myregistryname
export DOCKER_PASSWORD=myregistrytoken
export DOCKER_EMAIL=YOUR_EMAIL

kubectl create secret docker-registry cfcr\
--docker-server=$DOCKER_REGISTRY_SERVER\
--docker-username=$DOCKER_USER\
--docker-password=$DOCKER_PASSWORD\
--docker-email=$DOCKER_EMAIL
{% endraw %}
{% endhighlight %}

### Using the Docker registry secret

To use the secret you just created, you need to include it, either in:

* Your [pod manifests](https://kubernetes.io/docs/concepts/containers/#specifying-imagepullsecrets-on-a-pod){:target="\_blank"}
* The [service account](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account){:target="\_blank"}

For Docker registry secret usage, we recommend following the official Kubernetes documentation.

## Giving access to a Docker Registry via the Codefresh CLI

The Codefresh CLI can also create pull secrets in an automated manner.

See [Image pull Secret](https://codefresh-io.github.io/cli/more/image-pull-secret/){:target="\_blank"}.

## Related articles
[Deploy to Kubernetes - quick start]({{site.baseurl}}/docs/getting-started/deployment-to-kubernetes-quick-start-guide/)
[Managing your cluster]({{site.baseurl}}/docs/deployments/kubernetes/manage-kubernetes/)


146 changes: 146 additions & 0 deletions _docs/ci-cd-guides/add-config-maps-to-your-namespaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: "Adding config maps to namespaces"
description: "Manage Kubernetes Config Maps with Codefresh"
group: ci-cd-guides
toc: true
---
Many applications require configuration with files, environment variables, and command line arguments. It makes applications portable and easily manageable. While this makes for easy configuration, it can become very hard to support tons of config files for different environments and hundreds of microservices.

Kubernetes provides an elegant and very convenient way for application configuration, using *configuration maps*. You can find more details about config maps at [https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/){:target="_blank"}.

You can manage all your cluster configuration using Codefresh.

## View existing config maps

1. In the Codefresh UI, from the Ops section in the sidebar, select [**Kubernetes Services**](https://g.codefresh.io/kubernetes/services/){:target="\_blank"}.
1. Switch to list view.

{% include
image.html
lightbox="true"
file="/images/guides/config-maps/change-view.png"
url="/images/guides/config-maps/change-view.png"
alt="Change View"
caption="Change View"
max-width="50%"
%}

{:start="3"}
1. Select a namespace and hover over it.
1. Click the **Settings** icon which appears at the end of the row.
A list of all config maps within this namespace are displayed, including date of creation and number of configuration variables inside these maps.



## Add a new config map

1. From the list of config maps, click **Create a New Config Map**.

{% include image.html
lightbox="true"
file="/images/guides/config-maps/manage-maps-namespace.png"
url="/images/guides/config-maps/manage-maps-namespace.png"
alt="Create a new config map in namespace"
caption="Create a new config map in namespace"
max-width="40%"
%}

{:start="2"}
1. In the Add a New Config Map form, enter a **Name**, add variables, as described in [Managing variables in your config maps](#managing-variables-in-config-maps), and then click **Create**.

{% include image.html
lightbox="true"
file="/images/guides/config-maps/new-config-map-settings.png"
url="/images/guides/config-maps/new-config-map-settings.png"
alt="Define settings for new config map"
caption="Define settings for new config map"
max-width="40%"
%}

### Managing variables in config maps
There are three options to add variables to config maps:
1. Add a single variable at a time
1. Add multiple variables by copying and pasting from text or file
1. Import a set of variables from an existing config map


#### Add a single variable to config map

This is the easiest way to add a variable to the config map. This method is very useful to quickly create a small configmap with 1-2 variables:
1. Enter Key name and the Key value
1. Click **Add Variable**.

{% include image.html
lightbox="true"
file="/images/guides/config-maps/add-new-single-variable.png"
url="/images/guides/config-maps/add-new-single-variable.png"
alt="Add single variable at a time to config map"
caption="Add single variable at a time to config map"
max-width="40%"
%}


#### Import variables from text/file
If you already have configuration variables in a `*.property` file, you can easily import it to your configmap.

**Import from text**:


1. Click **Import from text**.
1. Copy text from file and paste it within the text area in the required format.
1. Click **Apply**.

{% include image.html
lightbox="true"
file="/images/guides/config-maps/import-variables-from-text.png"
url="/images/guides/config-maps/import-variables-from-text.png."
alt="Add multiple variables from text or file to config map"
caption="Add multiple variables from text or file to config map"
max-width="40%"
%}

**Import from file**:

1. Click **Import from file**.
1. Select the file from your computer, and click **Open**.


#### Copy variables from existing config map

You can easily copy the variables from an existing config map file, and use it in other namespaces.

1. Click **Copy from Existing Config Map**.
1. Select the **Cluster** and **Namespace** from which to copy the configmap.
1. Select the configmap from the list, and click **Select**.

{% include image.html
lightbox="true"
file="/images/guides/config-maps/select-cluster-namespace.png"
url="/images/guides/config-maps/select-cluster-namespace.png"
alt="Copy variables from existing config map"
caption="Copy variables from existing config map"
max-width="40%"
%}

### Edit/remove variables in config maps
You can easily edit or remove variables in your config maps.

1. Select the config map with the variables to modify or remove.
1. Click the **Edit** (pencil) icon.
1. Add new variables, as described in [Managing variables in your config maps](#managing-variables-in-config-maps).

{% include image.html
lightbox="true"
file="/images/guides/config-maps/edit-remove-config-map-variables.png"
url="/images/guides/config-maps/edit-remove-config-map-variables.png"
alt="Edit/remove variables in config maps"
caption="Edit/remove variables in config maps"
max-width="40%"
%}

To remove a config map, click on "remove" icon in the selected row. After your confirmation, the configmap will be removed.

## Related articles
[Connect to your Kubernetes cluster]({{site.baseurl}}/docs/integrations/add-kubernetes-cluster/)
[Manage your Kubernetes cluster]({{site.baseurl}}/docs/deployments/kubernetes/manage-kubernetes/)
[Deploy to Kubernetes - quick start]({{site.baseurl}}/docs/getting-started/deployment-to-kubernetes-quick-start-guide/)
Loading