34 Commits

Author SHA1 Message Date
Han Verstraete (OpenFaaS Ltd)
0451db85fa Fix generate command for read-only root filesystem setting
The readonly_root_filesystem setting was not included in the resulting
CRD when running faas-cli generate.

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
2022-09-20 16:48:56 +01:00
Lucas Roesler
b65e279f9f feat: Add missing fields to the describe output
Add the function
* constraints
* environment variables
* secrets
* requests and limits

This can be tested as follows:

Create a test cluster using KinD

```sh
kind create cluster --config=cluster.yaml
arkade install openfaas -a=false --function-pull-policy=IfNotPresent --wait

faas-cli store deploy nodeinfo --annotation sample=true --label status=418
```

Now deploy a sample function

```sh
$ faas-cli describe nodeinfo
Name:                nodeinfo
Status:              Ready
Replicas:            1
Available replicas:  1
Invocations:         0
Image:               ghcr.io/openfaas/nodeinfo:latest
Function process:    <default>
URL:                 http://127.0.0.1:8080/function/nodeinfo
Async URL:           http://127.0.0.1:8080/async-function/nodeinfo
Labels               faas_function : nodeinfo
                     status : 418
Annotations          sample : true
                     prometheus.io.scrape : false
Constraints          <none>
Environment          <none>
Secrets              <none>
Requests             <none>
Limits               <none>

```

Now we add some more interesting values, like a secret and env variables.

```sh
$ faas-cli secret create db-password --from-literal=password
Creating secret: db-password.
Created: 202 Accepted

$ faas-cli store deploy nodeinfo --annotation sample=true --label status=418 --secret db-password --env db-user=postgres --env db-host=rds.aws.example.com

Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/nodeinfo

$ faas-cli describe nodeinfo
Name:                nodeinfo
Status:              Ready
Replicas:            1
Available replicas:  1
Invocations:         0
Image:               ghcr.io/openfaas/nodeinfo:latest
Function process:    <default>
URL:                 http://127.0.0.1:8080/function/nodeinfo
Async URL:           http://127.0.0.1:8080/async-function/nodeinfo
Labels:              faas_function: nodeinfo
                     status: 418
                     uid: 736815901
Annotations:         prometheus.io.scrape: false
                     sample: true
Constraints:         <none>
Environment:         <none>
Secrets:              - db-password
Requests:            <none>
Limits:              <none>
```

To see how multiple Secrets and the Requests and Limits are rendered, use

```yaml
version: 1.0
provider:
  name: openfaas
  gateway: http://127.0.0.1:8080
functions:
  nodeinfo:
    lang: Dockerfile
    image: ghcr.io/openfaas/nodeinfo:latest
    secrets:
      - cache-password
      - db-password
    environment:
      db-host: rds.aws.example.com
      cache-host: redis.aws.example.com
    labels:
      status: 481
    annotations:
      sample: "true"
    requests:
      cpu: 100m
      memory: 128Mi
    limits:
      cpu: 200m
      memory: 256Mi
```
then

```sh
$ faas-cli secret create cache-password --from-literal=password
Creating secret: cache-password.
Created: 202 Accepted
$ faas-cli deploy
Deploying: nodeinfo.

Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/nodeinfo

$ faas-cli describe nodeinfo
Name:                nodeinfo
Status:              Ready
Replicas:            1
Available replicas:  1
Invocations:         0
Image:               ghcr.io/openfaas/nodeinfo:latest
Function process:    <default>
URL:                 http://127.0.0.1:8080/function/nodeinfo
Async URL:           http://127.0.0.1:8080/async-function/nodeinfo
Labels:              faas_function: nodeinfo
                     status: 481
                     uid: 679245186
Annotations:         prometheus.io.scrape: false
                     sample: true
Constraints:         <none>
Environment:         <none>
Secrets:             - cache-password
                     - db-password
Requests:            CPU: 100m
                     Memory: 128Mi
Limits:              CPU: 200m
                     Memory: 256Mi
```

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2022-03-17 15:45:19 +00:00
Alex Ellis (OpenFaaS Ltd)
b1c09c0243 Add usage metrics for describe command
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-01-26 16:28:03 +00:00
Alex Ellis (OpenFaaS Ltd)
77ad215bcc Generate annotations in OpenFaaS CR output
The faas-cli generate command was missing support for
annotations. Fixes: #890

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-06-03 08:50:11 +01:00
Carlos Panato
1ef557f974 build: fix image name when having the case registry:8080/foo/bar
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
2021-04-02 10:26:56 +01:00
Alex Ellis (OpenFaaS Ltd)
6914d950c9 Update alpha namespaces to v1
This should have been done before, but was missed.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-10-30 09:04:17 +00:00
Alex Ellis (OpenFaaS Ltd)
c8fbda1e86 Migrate to GA Knative serving service
The Knative serving service we were generating was out of
date, this PR changes that to work with the latest schema.

Changes have been tested with env vars and --tag=sha

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-10-16 14:10:43 +01:00
Martin Dekov
c12d57c39a Change api version in generate command
Changing api version in generate command since it was
outdated v1alpha2. The following changes took place:
* duplicated v1alpha2 package to v1 to avoid confusion
* updated examples to point to the right version
* updated default value to be v1 instead of v1alpha2
* fixed a bug where default namespace is unset

Signed-off-by: Martin Dekov <mvdekov@gmail.com>
2020-10-09 11:12:45 +01:00
Alex Ellis (OpenFaaS Ltd)
9f0cc07190 omitempty for the serving Annotations
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-07-01 21:37:01 +01:00
Alex Ellis (OpenFaaS Ltd)
defd7e46b3 Add annotations to revisionTemplate for knative
* Adds metadata to the knative spec in the generation command
* Fixes: #815

Tested by running locally and verifying it matched the request
from @Jeff-Lowrey

faas-cli generate \
  --api=serving.knative.dev/v1alpha1 \
  --annotation sidecar.istio.io/inject=true

This also works when bringing in annotations from the YAML
file.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-07-01 20:58:23 +01:00
Alex Ellis (OpenFaaS Ltd)
247ab62b5e Add comments to public structs
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-12-17 11:00:05 +00:00
Vivek Singh
5d6c4f2dee Move version in package name
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-11-05 16:03:35 +00:00
Vivek Singh
7971e8c388 Remove platform package, address review comments
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-11-05 16:03:35 +00:00
Vivek Singh
78db964048 Use new functions.json file for store
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-11-05 16:03:35 +00:00
Vivek Singh
b79a2e077d Use Secret struct from faas-provider
This commit updates the secret commands to use `Secret` struct from the
faas-provider rather than using it's own struct.

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-10-09 11:45:37 +01:00
Lucas Roesler
39c93555e4 Refactor exec and buildformat to improve type safety and clearer imports
**What**
- Create and move exec commands to a new exec package, this will make it
easier to reuse in the future "install" command
- Move git related commands to the versioncontrol package to keep the
git related commands together and easy to find.
- Implement flags interfaces for the BuildFormat so that the flags
package can set and validate this value directly and then we can
directly pass this value around to improve type safety in the throughout
- Renames the `tag` variable to `tagFormat` to improve readability, the
value is not directly the tag value and this could be confusing before.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2019-09-16 11:51:33 +01:00
Lucas Roesler
027157327f Initial support for tagging with git desribe output
**What**
- Adds new GetGitDescribe ouput command, use this command in the build,
deploy, generate, and push commands.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2019-09-16 11:51:33 +01:00
Lucas Roesler
495bc7042d Refactor to use provider log request schema
**What**
- Remove the log schema and replace with the schema defined in the
provider.  This ensures that the cli uses the same schema as the
providers.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2019-07-06 12:02:51 +01:00
Lucas Roesler
cde4cfdc16 Implement log streaming command
**What**
- Add schema for log request and response
- Add command for printing the log stream
- Support passing since value as timestamp or duration
- Add some unit tests

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2019-07-06 12:02:51 +01:00
Vivek Singh
d4c9b6fefc Refactor openfaas crd generation
This commit refactor openfaas crd schema puts it inside a package with
a version name so that it's easy to add new version for openfaas CRD

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-05-13 17:08:45 +01:00
Alex Ellis
c9544f53a9 Project secrets into knative CRD
This commit projects secrets into the Knative CRD YAML, however
it appears that the CRD validator for the Service object will
now allow multiple volumes to be mounted into the same directory
which breaks compatiability with OpenFaaS on Kubernetes.

A separate directory is used for each secret with the key so
that "aws" will be mounted at /var/openfaas/secrets/aws/name.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-05-11 15:40:52 +01:00
Alex Ellis
b42d0703b6 Add knative serving v1alpha1 to generate CRD command
This commit adds the ability to generate a knative serving
definition from the Function Store or a stack.yaml file with
a basic definition including: namespace, name, env-vars and
image.

Tested with Istio on Packet.net using figlet.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-05-11 12:42:20 +01:00
Vivek Singh
fd16b17a93 Add create command for secrets
This commit adds command to create new secrets from the CLI

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-01-11 10:57:54 +00:00
Vivek Singh
35312884d6 Add secret list command to faas-cli
This commit adds `faas-cli secret list` command to the faas-cli which
will be used to get secret list from the cluster.

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2019-01-10 09:03:33 +00:00
Vivek Singh
5a8b7e1fe4 Print labels and annotations in describe command
This commit prints labels and annotations in `faas-cli describe` command
whenever it is available.

Fixes: #533

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-10-13 20:48:54 +01:00
Vivek Singh
addc804953 Add changes required for reveiw comments
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-09-13 09:03:51 +01:00
Martin Dekov (VMware)
8c7957d4d0 Add annotation flag support to the deploy and store-deploy
Adding support for annotations through annotation flag
to the faas-cli deploy and store-deploy.

Signed-off-by: Martin Dekov (VMware) <mdekov@vmware.com>
2018-08-09 15:42:35 +01:00
James Smith
d8ff52e8bb Implement read-only root file system for store
Add `ReadOnlyRootFilesystem` to `StoreItem` schema and implement the
field within `commands/store_deploy.go`. This change will allow store
functions that are read-only to take affect.

Fixes: #490

Signed-off-by: James Smith <jamessmithsmusic@gmail.com>
2018-08-06 12:03:24 +01:00
Vivek Singh
3b5e7b7b80 Allow blank value for namespace
This commit add changes to allow blank value for namespace, which
removes namespace field from CRD definition file.

Also updated year for the copyright.

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-08-02 19:13:32 +01:00
Vivek Singh
cad006c2dc Add generate command to create CRD YAML files
This commit adds new subcommand `generate` faas-cli which can be used to
generate YAML file definition for Kubernetes CRD.

Output of this command can be piped to `kubectl` to apply to
Kubernetes cluster.

Usage: `faas-cli generate --api=openfaas.com/v1alpha2 --yaml fn-1.yml |
kubectl apply  -f -`

Fixes: #426

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-08-02 19:13:32 +01:00
Alex Ellis (VMware)
733313add1 Code review and fix-up for --tag
- Adds --tag=SHA option for build/push/deploy
- Corrects behaviour "tag" was not being honoured from the Docker
tag within the YAML file
- Did not work at all, had major blocking bug causing build to
fail to work by adding -t twice
- Wrote unit tests for new behaviour extracting new methods
- Introduced mode SHA / default and branch - branch-mode is yet to
be implemented
- Added final Docker image name to status updates in build command
- Tested with samples from faas-cli repo using --tag=SHA on/off

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-23 10:11:39 +01:00
Alex Ellis (VMware)
a0ee900685 Add cloud command for sealing secrets
Adds new command to seal a secret for use in OpenFaaS Cloud with
new subcommand "cloud". A sealed secret can be pushed into a
public Git repo without others being able to decrypt it.

The `kubeseal` CLI provides the implementation of the sealing
via exec - this is much less code and bloat than vendoring since
the kubeseal client API includes the Kubernetes Go client.

Command tested with SealedSecrets running on Kubernetes with
kubeadm and the faas-cli running on MacOS.

See README.md for usage and more instructions.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-06-05 12:17:18 -07:00
Minh-Quan TRAN
fabe085362 Fix parse env vars & add labels for store deploy command
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2018-02-02 10:03:15 +00:00
Amir Karimi
cdeb21d131 Move store item into schema package
Signed-off-by: Amir Karimi <a.karimi.k@gmail.com>
2018-01-19 08:49:51 +00:00