# First steps

> Deploy Apache NiFi on Kubernetes using manifest files. Verify setup and access NiFi's web interface with stackablectl or kubectl.

After going through the [Installation](https://docs.stackable.tech/home/stable/nifi/getting_started/installation/index.md) section and having installed all the operators, you deploy a NiFi cluster and the required dependencies. Afterward you can [verify that it works](https://docs.stackable.tech/home/stable/nifi/getting_started/first_steps/index.md) by querying the REST API.

## Setup

We are going to install a NiFi cluster by applying a manifest file. The operators create the resources according to the manifests.

The NiFi cluster requires authentication. Create a set of credentials for this purpose:

```bash
kubectl apply -f - <<EOF
---
apiVersion: v1
kind: Secret
metadata:
  name: simple-admin-credentials
stringData:
  admin: admin
---
apiVersion: authentication.stackable.tech/v1alpha1
kind: AuthenticationClass
metadata:
  name: simple-nifi-users
spec:
  provider:
    static:
      userCredentialsSecret:
        name: simple-admin-credentials
EOF
```

Afterwards create a NiFi instance:

```bash
kubectl apply -f - <<EOF
---
apiVersion: nifi.stackable.tech/v1alpha1
kind: NifiCluster
metadata:
  name: simple-nifi
spec:
  image:
    productVersion: 2.9.0
  clusterConfig:
    authentication:
      - authenticationClass: simple-nifi-users
    sensitiveProperties:
      keySecret: nifi-sensitive-property-key
      autoGenerate: true
  nodes:
    roleConfig:
      listenerClass: external-unstable
    roleGroups:
      default:
        replicas: 1
    # When NiFi is exposed through a NodePort Service it's SNI check has to be disabled
    configOverrides:
      nifi.properties:
        nifi.web.https.sni.required: "false"
        nifi.web.https.sni.host.check: "false"
EOF
```

## Verify that it works

First, make sure all pods are ready:

```bash
kubectl wait --for=condition=available --timeout=20m nificluster/simple-nifi
```

Then make sure the StatefulSets are ready:

```bash
kubectl get statefulset
```

The output should show all pods ready:

```
NAME                                 READY   AGE
simple-nifi-node-default             2/2     5m
```

Congratulations! You successfully created your first NiFi cluster!

### Access the NiFi web interface

You can retrieve the URL for the NiFi cluster web interface via `stackablectl` or `kubectl`.

#### stackablectl

Use the service command of `stackablectl` to get a list of all available endpoints:

```bash
stackablectl stacklet list
```

which should return something like this:

```
 PRODUCT    NAME         NAMESPACE  ENDPOINTS                           CONDITIONS
 nifi       simple-nifi  default    node-https https://172.18.0.2:30528 Available, Reconciling, Running
```

You can also use the `json` output and parse the endpoint:

```bash
nifi_url=$(stackablectl stacklet ls -o json | jq --raw-output '.[] | select(.name == "simple-nifi") | .endpoints["node-https"]')
```

Then connect to `[https://172.18.0.2:30528/nifi](https://172.18.0.2:30528/nifi)` and you should see the NiFi web login. After providing the username `admin` and password `admin` you are redirected to the NiFi web interface.

![nifi web ui](https://docs.stackable.tech/home/stable/nifi/_images/nifi-web-ui.png)

#### Via kubectl

You can also extract the endpoint from the [Listener](https://docs.stackable.tech/home/stable/listener-operator/listener/index.md) status via `kubectl`:

```bash
nifi_url=$(kubectl get listener simple-nifi-node -o 'jsonpath=https://{.status.ingressAddresses[0].address}:{.status.ingressAddresses[0].ports.https}') && \
echo "NiFi URL: $nifi_url"
```

should output a URL to connect to the NiFi web interface:

```
NiFi URL: https://172.18.0.2:30528
```

Then connect to `[https://172.18.0.2:30528/nifi](https://172.18.0.2:30528/nifi)` and you should see the NiFi web login. After providing the username `admin` and password `admin` you are redirected to the NiFi web interface.

## What’s next

Have a look at the [Usage guide](https://docs.stackable.tech/home/stable/nifi/usage_guide/index.md) page to find out more about the features of the NiFi Operator.
