New to Kubepack? Please start here.

Using Kubepack as an App User

How To Use

If you want to use others application with pack, then follow below instruction:

  1. Create a git repository.
  2. Create manifest.yaml file in the repository. See manifest.yaml doc.
  3. Add all the dependencies under dependencies in manifest.yaml file.
  4. Run kubectl plugin pack dep -v 10 to get all the dependencies in manifests/vendor folder.
  5. Run kubectl plugin pack edit -s <filepath>, if you want to change some file from manifests/vendor folder. This command will generate a patch under manifests/patch folder. manifests/vendor will be unchanged.
  6. Run kubectl plugin pack up to combine manifests/patch and manifests/vendor folder files. And final combination will be under manifests/output folder.
  7. Now, all is need to do kubectl apply -R -f manifests/output/. Then, your desired application will be deployed in kubernetes cluster.

Example

In this example, you’ll see how to deploy AppsCode kubed in minikube using Pack.

In this example, we’re using this test-case.

Below command show the manifest.yaml file.

$ cat manifest.yaml
package: github.com/kubepack/pack/_testdata/test-7
owners:
- name: Appscode
  email: [email protected]
dependencies:
- package: github.com/kubepack/test-kubed
  branch: master

manifest.yaml file contain test-kubed as dependencies. test-kubed contains all the necessary yaml file needs to deploy kubed in minikube cluster.

Now, kubectl plugin pack dep command will pull all the dependencies and place it in manifests/vendor folder. If test-kubed repository also depend on some other repository then pack will get that too.

  $ kubectl plugin pack dep
  $ tree manifests/vendor/
  
  manifests/vendor/
  └── github.com
      └── kubepack
          └── test-kubed
              ├── manifests
              │   └── app
              │       ├── deployment.yaml
              │       ├── kubed-config.yaml
              │       └── service.yaml
              └── manifest.yaml
  
  5 directories, 4 files

Now, all the dependencies in place. Now, we can edit manifests/vendor and this will generate patch.

We’re want to change kubed-config.yaml file, which is a secret yaml file.

    $ cat manifests/vendor/github.com/kubepack/test-kubed/manifests/app/kubed-config.yaml
    
    apiVersion: v1
    data:
      config.yaml: YXBpU2VydmVyOgogIGFkZHJlc3M6IDo4MDgwCiAgZW5hYmxlUmV2ZXJzZUluZGV4OiB0cnVlCiAgZW5hYmxlU2VhcmNoSW5kZXg6IHRydWUKY2x1c3Rlck5hbWU6IHVuaWNvcm4KZW5hYmxlQ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WluaWt1YmUKICBzYW5pdGl6ZTogdHJ1ZQogIHNjaGVkdWxlOiAnQGV2ZXJ5IDZoJwogIHN0b3JhZ2VTZWNyZXROYW1lOiBzbmFwLXNlY3JldAo=
    kind: Secret
    metadata:
      creationTimestamp: null
      labels:
        app: kubed
      name: kubed-config
      namespace: kube-system

We’ll change config.yaml under data field. config.yaml value will be YXBpU2VydmVyOgogIGFkZHJlc3M6IDo4MDgwCiAgZW5hYmxlUmV2ZXJzZUluZGV4OiB0cnVlCiAgZW5hYmxlU2VhcmNoSW5kZXg6IHRydWUKY2x1c3Rlck5hbWU6IHVuaWNvcm4KZW5hYmxlQ29uZmlnU3luY2VyOiB0cnVlCg==

$ kubectl plugin pack edit -s manifests/vendor/github.com/kubepack/test-kubed/manifests/app/kubed-config.yaml

Above command will open file in editor. Then, change config.yaml to above value. This will generate a patch in manifests/patch folder.

Below $ kubectl plugin pack up command will combine manifests/patch and manifests/vendor folder files and dump in manifests/output folder.

 $ kubectl plugin pack up
 $ kubectl apply -R -f manifests/output/

$ kubectl apply -R -f manifests/output/ command will deploy kubed in minikube cluster.

Next Steps

  • Take a look at how Kubepack handles various scenarios here.
  • Want to publish apps using Kubepack? Please visit here.
  • To learn about manifest.yaml file, please visit here.
  • Learn more about pack cli from here.

Subscribe to our free technical newsletter!

Join thousands of subscribers and stay up-to-date on AppsCode.