According to the ktx documentation I use the following code to check an image orientation:

char* pValue;
uint32_t valueLen;
if (KTX_SUCCESS == ktxHashList_FindValue(&kTexture->kvDataHead,
                                          &valueLen, (void**)&pValue))
      char s, t;
      if (sscanf(pValue, KTX_ORIENTATION2_FMT, &s, &t) == 2) 

When t equals “d” I know that data should be flipped (y axis). For testing I use ktx files from the ktx repository. It works fine with hi_mark.ktx but other ktx file - etc.ktx doesn’t contain KTXorientation (ktxHashList_FindValue returns KTX_INVALID_VALUE) and is rendered upside down. Infact many other ktx files doesn’t contain KTXorientation metadata. How should I handle it ? Maybe I should also flip data (y-axis) when an appropriate metadata is not available.

The default origin is upper-left with s increasing down so if there is no KTXorientation metadata you should indeed flip the data or, preferably, transform the texture coordinates.