[verb (plain)] + かのように [i-adj] + かのように [na-adj] + である + かのように [noun] + である / だった + かのように [verb (plain)] + かのようだ [verb (plain)] + かのような + [noun]
かのように means "as if" and describes how something is done: the action looks like it belongs to a situation that isn't real. It follows the plain form of a verb or an い-adjective, and a noun or な-adjective takes である, or だった for the past.
The の or な that a noun or な-adjective takes before ように does not work before かのように.
A clause with ように can describe something that really is so: "as". かのように always describes something that is not so, or that the speaker doesn't believe.
At the end of a sentence the same holds against ようだ, which can also be a guess from what you see: "it seems". かのようだ only compares, and adds that the comparison is not literally true.
These go beyond describing how something is done.
かのようだ ends the sentence: "it is as if". It conjugates like だ, so the past is かのようだった. Nouns and な-adjectives still take である: ×夢のかのようだ.
かのような describes the noun that follows.
かのように belongs to writing, narration and careful speech. In conversation the same comparison is みたいに, みたいだ or みたいな, usually with まるで.