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
66 changes: 61 additions & 5 deletions .github/workflows/api-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,63 @@ jobs:
run: |
go build ./...

build-packages:
build-darwin-packages:
needs: [ fmt-build-test ]
runs-on: macos-latest
defaults:
run:
working-directory: api-server
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.6'

- name: Build apiserver darwin packages
id: build
shell: bash
run: |
make -j dist/packages

- name: Upload apiserver tar.gz packages
uses: actions/upload-artifact@v4
with:
name: apiserver-darwin-packages-tar
if-no-files-found: error
path: |
./api-server/dist/packages/*.tar.gz

upload-s3-darwin-packages:
needs: ["build-darwin-packages"]
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
environment: registry-creds
if: ${{ github.event_name == 'push' }}
steps:
- name: download tar.gz binary artifacts
uses: actions/download-artifact@v4
with:
name: apiserver-darwin-packages-tar
path: ./dist/packages

- name: Display structure of downloaded files
run: ls -lah -R
working-directory: ./dist/packages

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
role-session-name: apiserver-ci-deploy
aws-region: us-east-1
- name: copy binaries to s3
run: |
aws s3 sync dist/packages s3://instructlab-ui/apiserver

build-linux-packages:
needs: [ fmt-build-test ]
runs-on: ubuntu-latest
defaults:
Expand All @@ -80,13 +136,13 @@ jobs:
- name: Upload apiserver tar.gz packages
uses: actions/upload-artifact@v4
with:
name: apiserver-packages-tar
name: apiserver-linux-packages-tar
if-no-files-found: error
path: |
./api-server/dist/packages/*.tar.gz

upload-s3-packages:
needs: ["build-packages"]
upload-s3-linux-packages:
needs: ["build-linux-packages"]
permissions:
id-token: write
contents: read
Expand All @@ -97,7 +153,7 @@ jobs:
- name: download tar.gz binary artifacts
uses: actions/download-artifact@v4
with:
name: apiserver-packages-tar
name: apiserver-linux-packages-tar
path: ./dist/packages

- name: Display structure of downloaded files
Expand Down
40 changes: 16 additions & 24 deletions api-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,33 @@ APISERVER_GCFLAGS?=
APISERVER_BUILD_PROFILE?=dev
APISERVER_LDFLAGS:=$(APISERVER_LDFLAGS) -X main.Version=$(APISERVER_VERSION)-$(APISERVER_RELEASE)

CGO_ENABLED?=0
CGO_ENABLED?=1
ifeq ($(APISERVER_RACE_DETECTOR),1)
CGO_ENABLED=1
APISERVER_BUILD_FLAGS+=-race
endif
ifneq ($(APISERVER_BUILD_TAGS),)
APISERVER_BUILD_FLAGS+=-tags $(APISERVER_BUILD_TAGS)
endif
ifeq ($(CGO_ENABLED),0)
APISERVER_LDFLAGS+=-extldflags=-static
endif

OS := $(shell uname -s)

# Crunchy DB operator does not work well on arm64, use an different overlay to work around it.
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),arm64)
OVERLAY?=arm64
ifeq ($(OS), Darwin)
TARGET_BIN = dist/apiserver-darwin-amd64 dist/apiserver-darwin-arm64
TARGET_PACKAGES= dist/packages/apiserver-darwin-amd64.tar.gz dist/packages/apiserver-darwin-arm64.tar.gz
else ifeq ($(OS), Linux)
TARGET_BIN = dist/apiserver-linux-amd64
#TARGET_BIN = dist/apiserver-linux-amd64 dist/apiserver-linux-arm64
TARGET_PACKAGES=dist/packages/apiserver-linux-amd64.tar.gz
#TARGET_PACKAGES=dist/packages/apiserver-linux-amd64.tar.gz dist/packages/apiserver-linux-arm64.tar.gz
else
OVERLAY?=dev
$(error Unsupported OS: $(OS))
endif

##@ Binaries

.PHONY: apiserver
apiserver: dist/apiserver dist/apiserver-linux-arm64 dist/apiserver-linux-amd64 dist/apiserver-darwin-amd64 dist/apiserver-darwin-arm64 ## Build Instructlab UI API server
apiserver: dist/apiserver $(TARGET_BIN) ## Build Instructlab UI API server

# Use go list to find all the go files that make up a binary.
APISERVER_DEPS:= $(shell go list -deps -f '{{if (and .Module (eq .Module.Path "github.com/instructlab/ui/api-server"))}}{{$$dir := .Dir}}{{range .GoFiles}}{{$$dir}}/{{.}} {{end}}{{end}}' ./)
Expand All @@ -67,23 +69,13 @@ dist/apiserver-%: $(APISERVER_DEPS) | dist
$(CMD_PREFIX) CGO_ENABLED=$(CGO_ENABLED) GOOS=$(word 2,$(subst -, ,$(basename $@))) GOARCH=$(word 3,$(subst -, ,$(basename $@))) \
go build $(APISERVER_BUILD_FLAGS) -gcflags="$(APISERVER_GCFLAGS)" \
-ldflags="$(APISERVER_LDFLAGS)" -o $@ ./
dist/packages: \
dist/packages/apiserver-linux-amd64.tar.gz \
dist/packages/apiserver-linux-arm64.tar.gz \
dist/packages/apiserver-darwin-amd64.tar.gz \
dist/packages/apiserver-darwin-arm64.tar.gz \
dist/packages: $(TARGET_PACKAGES)

dist/packages/%: apiserver
$(CMD_PREFIX) mkdir -p $(basename $(basename $@))
$(CMD_PREFIX) cp README.md $(basename $(basename $@))
$(CMD_PREFIX) cp dist/apiserver-$(subst apiserver-,,$(basename $(basename $(@F))))$(if $(findstring windows,$@),.exe) $(basename $(basename $@))/ilab-apiserver$(if $(findstring windows,$@),.exe)
$(CMD_PREFIX) if test "$(word 2,$(subst -, ,$(shell basename $@)))" = "windows" ; then \
printf " %-12s dist/packages/$(@F)\n" "[ZIP]" ;\
cd dist/packages && zip -q9r $(@F) $(basename $(basename $(@F))) ;\
else \
printf " %-12s dist/packages/$(@F)\n" "[TAR]" ;\
cd dist/packages && tar -czf $(@F) $(basename $(basename $(@F))) ;\
fi
$(CMD_PREFIX) cp dist/apiserver-$(subst apiserver-,,$(basename $(basename $(@F)))) $(basename $(basename $@))/ilab-apiserver$
$(CMD_PREFIX) printf " %-12s dist/packages/$(@F)\n" "[TAR]" ;
$(CMD_PREFIX) cd dist/packages && tar -czf $(@F) $(basename $(basename $(@F)));

.PHONY: clean
clean: ## clean built binaries
Expand Down
2 changes: 1 addition & 1 deletion api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (srv *ILabServer) runServer(cmd *cobra.Command, args []string) {
srv.ilabCmd = ilabPath
} else {
// Use ilab from virtual environment
srv.ilabCmd = filepath.Join(srv.baseDir, "venv", "bin", "ilab")
srv.ilabCmd = filepath.Join(srv.baseDir, "bin", "ilab")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this break the api server running in the default namespace if ilab isn’t copied into PATH? Add a flag if so plx sir.

Copy link
Member Author

@vishnoianil vishnoianil Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nerdalert venv is the name of virtual environment, user is to free to choose any name when they create the virtual environment. This installer now pass the entire path <venv-path>/<venv-name> to the apiserver. In this case it would be <venv-path>/venv. does that break anything in the apiserver?

if _, err := os.Stat(srv.ilabCmd); os.IsNotExist(err) {
srv.log.Fatalf("ilab binary not found at %s. Please ensure the virtual environment is set up correctly.", srv.ilabCmd)
}
Expand Down
61 changes: 56 additions & 5 deletions deploy/podman/native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,62 @@

Please follow the below instructions to deploy UI stack with Native mode enabled in Podman.

## Generate Secret
## Deploy using the installer (Recommended)

Make a temporary directory and download the installer

```shell
mkdir instructlab-ui
cd instructlab-ui

curl -fsSL https://raw.githubusercontent.com/instructlab/ui/refs/heads/main/installers/podman/ilab-ui-native-installer.sh
```

Give execution permission to the install

```shell
chmod a+x ilab-ui-native-installer.sh
```

Execute the installer and follow the instructions prompted on the terminal.

If your deployment machine has InstructLab (ilab CLI) setup, either on the host or in python virtual environment, use the following command

```shell
./ilab-ui-native-installer.sh --username <USERNAME> --password <PASSWORD>

e.g ./ilab-ui-native-installer.sh --username admin --password passw0rd
```

If your deployment machine don't have InstructLab CLI setup, please clone the taxonomy repo and fire the following command.

```shell
./ilab-ui-native-installer.sh --username <USERNAME> --password <PASSWORD> --taxonomy-dir <TAXONOMY_DIR>

e.g ./ilab-ui-native-installer.sh --username admin --password passw0rd --taxonomy-dir /Users/johndoe/instructlab/taxonomy
```

>[!NOTE]
> In the absence of InstructLab CLI, UI won't be able to support the synthetic data generation and fine tuning, but skill and knowledge contribution should work as expected.

If you are deploying the UI stack on a remote machine, please provide the auth url in the input

```shell
./ilab-ui-native-installer.sh --username <USERNAME> --password <PASSWORD> --taxonomy-dir <TAXONOMY_DIR> --auth-url http://<REMOTE-IP>:3000
```

Please use `--help` to see more options supported by the installer.

## Deploy manually

If you would like to install the UI stack manually, it's a two step process

- Generate the secret file with the required input
- Deploy the UI stack manifest file using podman.

A secret is required to provide required input to the UI stack in a secure way.

Two options exist to generate the secret, either using `kubectl` or filling in values in the `secret.yaml` provided.
There are two options to generate the secret's file, either using `kubectl` or filling in values in the `secret.yaml` provided.

### Generate secrets using kubectl

Expand Down Expand Up @@ -46,17 +97,17 @@ echo "password" | base64

Using the above to fill in all the required input fields.

## Deploy the secret
### Deploy the secret

Now that the `secret.yaml` has been generated, use `podman kube play` to load the secret.

```bash
podman kube play secret.yaml
```

## Deploying the InstructLab UI Stack
### Deploy the InstructLab UI Stack

One last step before you launch the InstructLab UI. A file named [instructlab-ui.yaml](instructlab-ui.yaml) present in the [native](../native/) directory. Search for <TAXONOMY_REPO_ROOT_DIR> in the yaml file and replace it with the same value that is used while creating the secret.yaml file. Now with the secret in place and deployment yaml updated, use `podman kube play` to launch the containers. UI will look for the taxonomy repo in this directory to submit the skill and knowledge contributions.
One last step before you launch the InstructLab UI. A file named [instructlab-ui.yaml](instructlab-ui.yaml) present in the [native](../native/) directory. Search for <TAXONOMY_ROOT_DIR> in the yaml file and replace it with the same value that is used while creating the secret.yaml file. Now with the secret in place and deployment yaml updated, use `podman kube play` to launch the containers. UI will look for the taxonomy repo in this directory to submit the skill and knowledge contributions.

```bash
podman kube play instructlab-ui.yaml
Expand Down
2 changes: 1 addition & 1 deletion deploy/podman/native/instructlab-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,5 @@ spec:
volumes:
- name: taxonomy-repo
hostPath:
path: <TAXONOMY_REPO_ROOT_DIR>
path: <TAXONOMY_ROOT_DIR>
type: Directory
16 changes: 8 additions & 8 deletions deploy/podman/native/secret.yaml.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
data:
IL_ENABLE_DEV_MODE: ZmFsc2U=
IL_UI_ADMIN_PASSWORD:
IL_UI_ADMIN_USERNAME:
IL_UI_DEPLOYMENT: bmF0aXZl
NEXT_PUBLIC_EXPERIMENTAL_FEATURES: dHJ1ZQ==
NEXT_PUBLIC_TAXONOMY_ROOT_DIR:
NEXTAUTH_SECRET:
NEXTAUTH_URL: aHR0cDovL2xvY2FsaG9zdDozMDAw
IL_UI_ADMIN_PASSWORD: <PASSWORD>
IL_UI_ADMIN_USERNAME: <USERNAME>
IL_UI_DEPLOYMENT: <UI_DEPLOYMENT>
IL_ENABLE_DEV_MODE: <DEV_MODE>
NEXT_PUBLIC_EXPERIMENTAL_FEATURES: <EXPERIMENTAL_FEATURES>
NEXT_PUBLIC_TAXONOMY_ROOT_DIR: <TAXONOMY_ROOT_DIR>
NEXTAUTH_URL: <AUTH_URL>
NEXTAUTH_SECRET: <AUTH_SECRET>
kind: Secret
metadata:
creationTimestamp: null
Expand Down
Loading
Loading